comparison testing/utp_1.1/generic_utps/utp_65.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
2 % <TestDescription>
3 %
4 % Tests that the contructed object can be submitted and retrieved.
5 %
6 % </TestDescription>
7 function result = utp_65(cl, obj1, ple3)
8
9 % <SyntaxDescription>
10 %
11 % Tests that the contructed object can be submitted and retrieved.
12 %
13 % </SyntaxDescription>
14
15 msg = '';
16 try
17 % <SyntaxCode>
18 pl = plist('hostname', utpGetHostname, ...
19 'database', utpGetDatabase, ...
20 'username', utpGetUsername, ...
21 'password', utpGetPassword, ...
22 'experiment title', 'utp_65: submit objects', ...
23 'experiment description', 'utp_65: test submission', ...
24 'analysis description', 'no analysis', ...
25 'no dialog', true, ...
26 'use selector', false);
27
28 ids = submit(obj1, pl);
29
30 out = feval(cl, plist('hostname', utpGetHostname, ...
31 'database', utpGetDatabase, ...
32 'username', utpGetUsername, ...
33 'password', utpGetPassword, ...
34 'id', ids));
35 % </SyntaxCode>
36 stest = true;
37 catch err
38 msg = err.message;
39 disp(err.message)
40 % Close connection
41 stest = false;
42 end
43
44 % <AlgoDescription>
45 %
46 % 1) Check that the last entry in the history of 'out' corresponds to
47 % the class name.
48 % 2) Check that the 'rebuild' method produces the same object as 'out'.
49 %
50 % </AlgoDescription>
51
52 atest = true;
53 if stest
54 % <AlgoCode>
55 % Check the last step in the history of 'out'
56 for kk = 1:numel(out)
57 if ~strcmp(out(kk).hist.methodInfo.mname, cl)
58 msg = ['The last step in the history is not ''' cl ''''];
59 atest = false;
60 end
61 end
62 % Check data values
63 if ~eq(out, obj1, ple3)
64 msg = ['The values in the objects are not equal: ' lastwarn];
65 atest = false;
66 end
67 % Check the history
68 if ~eq(out.hist.inhists, obj1.hist)
69 msg = ['The history of the objects are not equal: ' lastwarn];
70 atest = false;
71 end
72
73 % Rebuild the retrieved object
74 % rout = rebuild(out);
75 % if ~eq(rout, out, ple3), atest = false; end
76 % </AlgoCode>
77 else
78 atest = false;
79 end
80
81 % Return a result structure
82 dd = dbstack;
83 mfilename = dd(2).file(1:end-2);
84 result = utp_prepare_result(atest, stest, dbstack, mfilename, msg);
85 end % END UTP_65