-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_combo_string.m
47 lines (41 loc) · 1.33 KB
/
test_combo_string.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
function e=test_combo_string(s)
% test_combo_string(s) runs tests on combo_string
% and returns number of failed tests
% also prints out info about tests
% author: Huimin Jia
% add two tests for this function by Kai Wu
% another test added by Gabriel Bronk
% the 'good study' test was modified by Gabriel Bronk
% the "4989 12" test was modified by Gabriel Bronk
e=0;
e = e+ runtest('a','bb','abba');
e = e+ runtest('bb','a','abba');
e = e+ runtest('ab','cddg','abcddgab');
e = e+ runtest('','Hi','Hi');
e = e+ runtest('Hi','','Hi');
e = e+ runtest('aa','bb','error');
e = e+ runtest('','','error');
e = e+ runtest('45','2','2452');
e = e+ runtest('hhh','h','hhhhh');
<<<<<<< HEAD
e = e+ runtest('4989','12','12498912');
e = e+ runtest('good','study','goodstudygood');
e = e+ runtest('22hh','7g8j9k','22hh7g8j9k22hh');
=======
e = e+ runtest('4989','12','498912');
e = e+ runtest('good','study','goodgoodstudy');
e = e+ runtest('HELLO','12','12HELLO12');
>>>>>>> 966be1c5031e93b7373ec4dfa0f7a6abdf1751d7
end
function e=runtest(a,b,answer)
% runtest(a,b,answer) - runs the combo_string test
result= combo_string(a,b);
if strcmp(result,answer)
e=0;
fprintf(' combo_string(%s,%s)=%s\n',a,b,answer);
else
e=1;
fprintf('ERROR: combo_string(%s,%s)->%s <> %s\n',
a,b,result,answer);
end;
end