forked from tjhickey724/OctaveBat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_inOrder.m
executable file
·41 lines (34 loc) · 1.08 KB
/
test_inOrder.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
function e=test_inOrder()
% test_inOrder runs several tests and returns
% the number of tests that fail
% Author: Siddhi Krishna
% Date: 2/21/2011
% Add two tests for this function by Kai Wu
e=0;
e = e + runtest(1,2,3,true);
e = e + runtest(2,1,3,false);
e = e + runtest(1,1,1,false);
e = e + runtest(2,2,1,false);
e = e + runtest(10,20,20,false);
e = e + runtest(10,20,30, true);
e = e + runtest(10,19,20, true);
e = e + runtest(-1, 0, 1, true);
e = e + runtest(-1,-1, 0, true);
e = e + runtest(-1,-1, -2, false);
e = e + runtest(30,30,50, true); % by Kai Wu
e = e + runtest(15,30,15, true); % by Kai Wu
end
function e=runtest(a,b,c,answer)
% runtest(a,b,c, answer) - calls inOrder(a,b,c)
% to get the result, compares with the answer
% and returns 1 if an error 0 if not
% also prints out the test results ...
result = inOrder(a,b,c);
if (result == answer)
e=0;
fprintf(' inOrder(%d,%d,%d)=%d\n',a,b,c,result);
else
e=1;
fprintf('ERROR:inOrder(%d,%d,%d)->%d <> %d\n',a,b,c,result,answer);
end
end