-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fac.m
More file actions
35 lines (28 loc) · 774 Bytes
/
test_fac.m
File metadata and controls
35 lines (28 loc) · 774 Bytes
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
function test_suite=test_fac
% initialize unit tets
try
test_functions=localfunctions();
catch
end
initTestSuite;
%%%%%%%%%%%%%%%%%%%%%%%
% Basic tests %
%%%%%%%%%%%%%%%%%%%%%%%
function test_fac_0
% test if fac(0)==1
assertEqual(fac(0),1);
function test_fac_1
% test if fac(1)==1
assertEqual(fac(1),1);
function test_fac_5
% test if fac(5)==120
assertEqual(fac(5),120);
%%%%%%%%%%%%%%%%%%%%%%%
% More advanced tests %
%%%%%%%%%%%%%%%%%%%%%%%
function test_fac_exception_negative
% test if exceptions are thrown for negative values
assertExceptionThrown(@()fac(-1));
function test_fac_exception_noninteger
% test if exceptions are thrown for noninteger values
assertExceptionThrown(@()fac(1.5),'*');