forked from tjhickey724/OctaveBat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_hasTeen.m
executable file
·57 lines (45 loc) · 1.66 KB
/
test_hasTeen.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function y = test_hasTeen();
% test_hasTeen runs several tests
% on the hasTeen function, displays hasTeen's
% output for each test,
% and returns the number of tests that fail.
% Author: Gabriel Bronk
% 3/2/11
%Mehreen Asad (Added 2 new test cases)
%
% Test by Adam Rosenbloom on 5-2-11
% On lines 52 to 53 the fprintf statement was proken up into two lines, I
% put the elipsis (...) that is necessary to break up the line in MATLAB...
% Apparently this must not be ecessary in Octave. Also added two test cases.
y = 0;
y = y + runtest(12,20,13,true);
y = y + runtest(12,19,20,true);
y = y + runtest(19,20,12,true);
y = y + runtest(19,20,13,true);
y = y + runtest(19,18,13,true);
y = y + runtest(12,20,100,false);
y = y + runtest(90,12,20,false);
y = y + runtest(14,15,16,true);
y = y + runtest(12,12,12,false);
y = y + runtest(13,13,13,true);
y = y + runtest(-2,0,4,false);
y = y + runtest(12,16,1,true);
y = y + runtest(13, 12, 20, true); % Added by ASR
y = y + runtest(12, 20, 12, false); % Added by ASR
y = y + runtest(-13,-15,5,false); %Added by Liz Li
end
function q = runtest(a,b,c,answer);
% runtest(a,b,c,answer) calls hasTeen(a,b,c)
% to get the result, compares with the answer
% and returns 1 if an error, 0 if not.
% It also prints out the test results.
result = hasTeen(a,b,c);
if (result == answer);
q = 0;
fprintf(' hasTeen(%d,%d,%d)=%d\n',a,b,c,result);
else
q = 1;
fprintf('ERROR:hasTeen(%d,%d,%d)->%d <> %d\n', ... % Note the elipsis required by MATLAB syntax
a,b,c,result,answer);
end
end