comparison testing/utp_1.1/generic_utps/utp_62.m @ 44:409a22968d5e default

Add unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 18:42:11 +0100
parents
children
comparison
equal deleted inserted replaced
43:bc767aaa99a8 44:409a22968d5e
1 % <TestDescription>
2 %
3 % Tests that the constructor properly applies history in the struct constructor.
4 %
5 % </TestDescription>
6 function result = utp_62(cl, obj1, obj2, ple2)
7
8 % <SyntaxDescription>
9 %
10 % Tests that the constructor properly applies history in the struct constructor.
11 %
12 % </SyntaxDescription>
13
14 msg = '';
15 try
16 % <SyntaxCode>
17 ssys1 = utils.prog.rstruct(obj1);
18 ssys1.hist = utils.prog.rstruct(obj1.hist);
19
20 out1 = feval(cl, utils.prog.rstruct(obj2));
21 out2 = feval(cl, ssys1);
22 mout1 = rebuild(out1);
23 mout2 = rebuild(out2);
24 % </SyntaxCode>
25 stest = true;
26 catch err
27 msg = err.message;
28 disp(err.message)
29 stest = false;
30 end
31
32 % <AlgoDescription>
33 %
34 % 1) Check that the last entry in the history of 'out'
35 % corresponds to the class name.
36 % 2) Check that the 'rebuild' method produces the same object as 'out'.
37 %
38 % </AlgoDescription>
39
40 atest = true;
41 if stest
42 % <AlgoCode>
43 % Check that the output is a ssm object
44 if ~isa(out1,cl), atest = false; end
45 if ~isa(out2,cl), atest = false; end
46 % Check the last step in the history of 'out'
47 if ~strcmp(out1.hist.methodInfo.mname, 'setName')
48 msg = 'The last step in the history is not ''setName''';
49 atest = false;
50 end
51 if ~strcmp(out2.hist.methodInfo.mname, 'setName')
52 msg = 'The last step in the history is not ''setName''';
53 atest = false;
54 end
55 % Check the rebuilt object
56 if ~eq(mout1, out1, ple2)
57 msg = ['The original and rebuilt objects are not equal: ' lastwarn];
58 atest = false;
59 end
60 if ~eq(mout2, out2, ple2)
61 msg = ['The original and rebuilt objects are not equal: ' lastwarn];
62 atest = false;
63 end
64 % </AlgoCode>
65 else
66 atest = false;
67 end
68
69 % Return a result structure
70 dd = dbstack;
71 mfilename = dd(2).file(1:end-2);
72 result = utp_prepare_result(atest, stest, dbstack, mfilename, msg);
73 end % END UTP_62