comparison testing/utp_1.1/generic_utps/utp_genericHistory.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 <METHOD> method properly applies history.
4 %
5 % </TestDescription>
6 function result = utp_genericHistory(method, obj, args, ple)
7
8 % <SyntaxDescription>
9 %
10 % Test that the result of applying the <METHOD> method can be processed
11 % back.
12 %
13 % </SyntaxDescription>
14
15 try
16 % <SyntaxCode>
17 if isempty(args)
18 out = feval(method, obj);
19 else
20 if iscell(args)
21 out = feval(method, obj, args{:});
22 else
23 out = feval(method, obj, args);
24 end
25 end
26 mout = rebuild(out);
27 % </SyntaxCode>
28 stest = true;
29 catch err
30 disp(err.message)
31 stest = false;
32 end
33
34 % <AlgoDescription>
35 %
36 % 1) Check that the last entry in the history of 'out' corresponds to
37 % '<METHOD>'.
38 % 2) Check that the re-built object is the same object as the input.
39 %
40 % </AlgoDescription>
41
42 atest = true;
43 if stest
44 % <AlgoCode>
45 % Check the last step in the history of 'out'
46 if ~strcmp(out.hist.methodInfo.mname, method), atest = false; end
47 % The rebuilt object must be the same as 'out'
48 if ~eq(mout, out, ple), atest = false; end
49 % </AlgoCode>
50 else
51 atest = false;
52 end
53
54 % Return a result structure
55 result = utp_prepare_result(atest, stest, dbstack, ['utp_' class(obj) '_' method]);
56 end
57
58
59
60