comparison testing/utp_1.1/generic_utps/utp_64.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 contructor properly applies history to the
4 % plist(filename) constructor.
5 %
6 % </TestDescription>
7 function result = utp_64(cl, obj1, ple1, ple2)
8
9 % <SyntaxDescription>
10 %
11 % Tests that the contructor properly applies history to the
12 % plist(filename) constructor.
13 %
14 % </SyntaxDescription>
15
16 msg = '';
17 try
18 % <SyntaxCode>
19 filename1 = 'obj.xml';
20 filename2 = 'obj.mat';
21
22 f1 = feval(cl, obj1);
23
24 save(f1, filename1);
25 save(f1, filename2);
26
27 out1 = feval(cl, plist('filename', filename1));
28 out2 = feval(cl, plist('filename', filename2));
29
30 rout1 = out1.rebuild;
31 rout2 = out2.rebuild;
32
33 % </SyntaxCode>
34 stest = true;
35 catch err
36 msg = err.message;
37 disp(err.message)
38 stest = false;
39 end
40
41 % <AlgoDescription>
42 %
43 % 1) Check that the save method doesn't change the input object
44 % 2) Check that the 'rebuild' method produces the same object as 'out'.
45 %
46 % </AlgoDescription>
47
48 atest = true;
49 if stest
50 % <AlgoCode>
51 % The load doesn't have two additionally history steps (save + load)
52 if ~eq(out1, f1, ple1)
53 msg = ['The history of the objects are not equal: ' lastwarn];
54 atest = false;
55 end
56 if ~eq(out2, f1, ple1)
57 msg = ['The history of the objects are not equal: ' lastwarn];
58 atest = false;
59 end
60 % Rebuild object and check the result
61 if ~eq(rout1, out1, ple2)
62 msg = ['The original and rebuilt objects are not equal: ' lastwarn];
63 atest = false;
64 end
65 if ~eq(rout2, out2, ple2)
66 msg = ['The original and rebuilt objects are not equal: ' lastwarn];
67 atest = false;
68 end
69 % </AlgoCode>
70 % delete test file
71 delete(filename1)
72 delete(filename2)
73 else
74 atest = false;
75 end
76
77 % Return a result structure
78 dd = dbstack;
79 mfilename = dd(2).file(1:end-2);
80 result = utp_prepare_result(atest, stest, dbstack, mfilename, msg);
81 end % END UTP_64
82