comparison testing/utp_1.1/generic_utps/utp_genericModify.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 can modify the input AO.
4 %
5 % </TestDescription>
6 function result = utp_genericModify(method, obj, args, algo, ple)
7
8 % <SyntaxDescription>
9 %
10 % Test that the <METHOD> method can modify the input object by calling
11 % with no output and that the method doesn't change the input of the
12 % function notation (with a equal sign).
13 %
14 % </SyntaxDescription>
15
16 try
17 % <SyntaxCode>
18 obj_modi = copy(obj,1);
19 obj_eq = copy(obj,1);
20 if iscell(args)
21 out = feval(method, obj_eq, args{:});
22 feval(method, obj_modi, args{:});
23 else
24 out = feval(method, obj_eq, args);
25 feval(method, obj_modi, args);
26 end
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 modified input is changed by the method
37 % 2) Check that 'out' and 'obj_eq' are now different.
38 % 3) Check that 'obj_eq' is not changed
39 % 4) Check that out and amodi are the same
40 %
41 % </AlgoDescription>
42
43 atest = true;
44 if stest
45 % <AlgoCode>
46 % Check that obj_modi is changed
47 atest = algo(obj, obj_modi, 1, args);
48 % Check that 'out' and 'obj_eq' are now different.
49 if eq(out, obj_eq, ple), atest = false; end
50 % Check that 'obj_eq' is not changed
51 if ~eq(obj_eq, obj, ple), atest = false; end
52 % Check that out and obj_modi are the same
53 if ~eq(out, obj_modi, ple), atest = false; end
54
55 % </AlgoCode>
56 else
57 atest = false;
58 end
59
60 % Return a result structure
61 result = utp_prepare_result(atest, stest, dbstack, ['utp_' class(obj) '_' method]);
62 end
63
64
65
66
67