forked from tjhickey724/OctaveBat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_sumDigit.m
executable file
·53 lines (34 loc) · 998 Bytes
/
test_sumDigit.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
% Tarif Riyad Rahman
% MATLAB syntax used
% This is the test bed for the function sumDigit
% sample cases are used for testing the correctness of the function
%Modified by Ritu Pradhan
%Added 3 test cases and modified the error statement to display Error message.
% new test cases added by Tarif Riyad Rahman
function e=test_sumDigit()
e=0;
e=e+runtest(32,5);
e=e+runtest(53,8);
e=e+runtest(953,17);
e=e+runtest(103,4);
e=e+runtest(4944,21);
e=e+runtest(256,13);
e=e+runtest(5121,9);
e=e+runtest(1216,10);
e=e+runtest(2532,12);
e=e+runtest(121,4);
e=e+runtest(1111,4);
e=e+runtest(0,0);
e=e+runtest(10,1);
e=e=runtest(121,4); % added by tarif riyad rahman
end
function e=runtest(n,answer)
result=sumDigit(n);
if result==answer
e=0;
fprintf('sumDigit(%d)=%d\n',n,result);
else
e=1;
fprintf('ERROR:sumDigit(%d)=%d<>%d\n',n,result,answer);
end
end