Mercurial > hg > ltpda
comparison testing/utp_1.1/generic_utps/utp_07.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_07(method, obj1, ipl, ple1) | |
7 | |
8 % <SyntaxDescription> | |
9 % | |
10 % Test that the <METHOD> method can modify the input object by calling with no | |
11 % output and that the method doesn't change the input of the function | |
12 % notation (with a equal sign). | |
13 % | |
14 % </SyntaxDescription> | |
15 | |
16 try | |
17 % <SyntaxCode> | |
18 obj_modi = copy(obj1,1); | |
19 obj_eq = copy(obj1,1); | |
20 cmd = sprintf('out = obj_eq.%s(ipl);', method); | |
21 eval(cmd); | |
22 cmd = sprintf('obj_modi.%s(ipl);', method); | |
23 eval(cmd); | |
24 % </SyntaxCode> | |
25 stest = true; | |
26 catch err | |
27 disp(err.message) | |
28 stest = false; | |
29 end | |
30 | |
31 % <AlgoDescription> | |
32 % | |
33 % 1) Check that 'out' and 'aeq' are now different. | |
34 % 2) Check that 'aeq' is not changed | |
35 % 3) Check that the modified input is the <METHOD> value of the copy | |
36 % 4) Check that out and amodi are the same | |
37 % | |
38 % </AlgoDescription> | |
39 | |
40 atest = true; | |
41 if stest | |
42 % <AlgoCode> | |
43 % Check that 'out' and 'obj_eq' are now different. | |
44 if eq(out, obj_eq, ple1), atest = false; end | |
45 % Check that 'obj_eq' is not changed | |
46 if ~eq(obj_eq, obj1, ple1), atest = false; end | |
47 | |
48 switch class(obj1) | |
49 case 'ao' | |
50 if isempty(ipl) || isempty(find(ipl, 'neval')) | |
51 % Check that the modified input is correct | |
52 if ~isequal(feval(method, obj1.data.getY), obj_modi.data.getY), atest = false; end | |
53 end | |
54 % Check that out and obj_modi are the same | |
55 if ~eq(out, obj_modi, ple1), atest = false; end | |
56 otherwise | |
57 warning('!!! test is undefined for class %s', class(obj_modi)); | |
58 atest = false; | |
59 end | |
60 % </AlgoCode> | |
61 else | |
62 atest = false; | |
63 end | |
64 | |
65 % Return a result structure | |
66 dd = dbstack; | |
67 mfilename = dd(2).file(1:end-2); | |
68 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
69 end % END UTP_07 |