comparison testing/utp_1.1/generic_utps/utp_61.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 to the read
4 % XML-file constructor.
5 %
6 % </TestDescription>
7 function result = utp_61(cl, obj1, ple2)
8
9 % <SyntaxDescription>
10 %
11 % Tests that the constructor properly applies history to the read
12 % XML-file constructor.
13 %
14 % </SyntaxDescription>
15
16 msg = '';
17 try
18 % <SyntaxCode>
19 filename = 'obj.xml';
20 amat = feval(cl, obj1);
21 save(amat, filename);
22
23 out = feval(cl, filename);
24 mout = rebuild(out);
25 % </SyntaxCode>
26 stest = true;
27 catch err
28 msg = err.message;
29 disp(err.message)
30 stest = false;
31 end
32
33 % <AlgoDescription>
34 %
35 % 1) Check that the history is the same as the history of the saved
36 % object. Because save and load shouldn't add a history step.
37 % 2) Check that the 'rebuild' method produces the same object as 'out'.
38 %
39 % </AlgoDescription>
40
41 atest = true;
42 if stest
43 % <AlgoCode>
44 % Check the last step in the history of 'out'
45 if ~eq(out, amat)
46 msg = ['The original and rebuilt objects are not equal: ' lastwarn];
47 atest = false;
48 end
49
50 % Check the rebuilt object
51 for kk = 1:numel(out)
52 if ~eq(mout(kk), out(kk), ple2)
53 msg = ['The original and rebuilt objects are not equal: ' lastwarn];
54 atest = false;
55 end
56 end
57 % </AlgoCode>
58 delete(filename);
59 else
60 atest = false;
61 end
62
63 % Return a result structure
64 dd = dbstack;
65 mfilename = dd(2).file(1:end-2);
66 result = utp_prepare_result(atest, stest, dbstack, mfilename, msg);
67 end % END UTP_09