forked from tjhickey724/OctaveBat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_getSandwich.m
executable file
·30 lines (28 loc) · 1.14 KB
/
test_getSandwich.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
function err = test_getSandwich()
%Modified By Ritu Pradhan
%Added 3 testcases
err = 0;
err = err + runTestSandwich('breadjellybread', 'jelly');
err = err + runTestSandwich('xxbreadjellybreadjellyxxbread', 'jellybreadjellyxx');
err = err + runTestSandwich('xxbreadxxxx', '');
err = err + runTestSandwich('brxxeadxxbreadjambread', 'jam');
err = err + runTestSandwich('breadbreadbreadbread', 'breadbread');
err = err + runTestSandwich('breadjuicyhamandturkeybreadmoreturkeybread', 'juicyhamandturkeybreadmoreturkey');
err = err + runTestSandwich('turkeybreadham', '');
err = err + runTestSandwich('breadporkxbrxreadxbredbradbread', 'porkxbrxreadxbredbrad');
err = err + runTestSandwich('bread', '');
err = err + runTestSandwich('breadbread', '');
err = err + runTestSandwich('abc', '');
err = err + runTestSandwich('xyzbreadbreadbreadxyz', 'bread');
err = err + runTestSandwich('bread1234bread', '1234');
end
function x = runTestSandwich(s, correct)
ansr = getSandwich(s);
if strcmp(ansr, correct)
x=0;
fprintf('getSandwich(%s) --> %s\n', s, ansr);
else
x=1;
fprintf('ERROR! getSandwich(%s) --> %s\n', s, ansr);
end
end