-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_linearIn.m~
38 lines (33 loc) · 1.11 KB
/
test_linearIn.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
function e = test_countClumps()
#Jeremy Patton
#Tested by:
#
#1. Josh Silverman
#2. Ben Setel (Added the test at the end)
e=0;
e+=runTest([1, 2, 2, 3, 4, 4, 2], 2);
e+=runTest([1, 1, 2, 1, 1], 2);
e+=runTest([1, 1, 1, 1, 1], 1);
e+=runTest([1, 2, 3], 0);
e+=runTest([2, 2, 1, 1, 1, 2, 1, 1, 2, 2], 4);
e+=runTest([0, 2, 2, 1, 1, 1, 2, 1, 1, 2, 2], 4);
e+=runTest([0, 0, 2, 2, 1, 1, 1, 2, 1, 1, 2, 2] , 5);
e+=runTest([0, 0, 0, 2, 2, 1, 1, 1, 2, 1, 1, 2, 2], 5);
e+=runTest([], 0);
e+=runTest([1, 1, 1, 1, 1], 1);
e+=runTest([0, 2, 3, 2, 1, 4, 1, 5, 1, 2, 1, 6, 1, 2, 2], 1);
e+=runTest([0, 0, 2, 2, 1, 1, 1, 2, 1, 1, 2] , 4);
e+=runTest([0, 0, 0, 2, 2, 1, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], 5);
e+=runTest([-1, -1, 2, 2, 1, -1], 2);
e+=runTest([11 1 1 22 2 2 2 22], 2); #added
end
function k=runTest(nums, answer)
result=linearIn(nums);
if(result==answer)
k=0;
printf(" countClumps([");printf("%i ", nums);printf("]) %d -> %d\n", result, answer);
else
k=1;
printf("ERROR! countClumps([");printf("%d ", nums);printf("]) %d <> %d\n", result, answer);
end
end