Mercurial > hg > ltpda
comparison testing/utp_1.1/generic_utps/utp_genericOutput.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 % Check that the <METHOD> method pass back the output objects to a list of | |
4 % output variables or to a single variable. | |
5 % | |
6 % </TestDescription> | |
7 function result = utp_genericOutput(method, obj1, obj2, args, algo, ple) | |
8 | |
9 % <SyntaxDescription> | |
10 % | |
11 % Call the method with a list of output variables and with a single output | |
12 % variable. Additionaly check that the rebuild method works on the output. | |
13 % | |
14 % </SyntaxDescription> | |
15 | |
16 try | |
17 % <SyntaxCode> | |
18 if iscell(args) | |
19 [o1, o2] = feval(method, obj1, obj2, args{:}); | |
20 o3 = feval(method, obj1, obj2, args{:}); | |
21 else | |
22 [o1, o2] = feval(method, obj1, obj2, args); | |
23 o3 = feval(method, obj1, obj2, args); | |
24 end | |
25 mout1 = rebuild(o1); | |
26 mout2 = rebuild(o2); | |
27 mout3 = rebuild(o3); | |
28 % </SyntaxCode> | |
29 stest = true; | |
30 catch err | |
31 disp(err.message) | |
32 stest = false; | |
33 end | |
34 | |
35 % <AlgoDescription> | |
36 % | |
37 % 1) Check that the output contains the right number of objects | |
38 % 2) Check that the 'rebuild' method produces the same object as 'out'. | |
39 % | |
40 % </AlgoDescription> | |
41 | |
42 atest = true; | |
43 if stest | |
44 % <AlgoCode> | |
45 % Check the outputs | |
46 t1 = algo(obj1, o1, 1, args); | |
47 t2 = algo(obj2, o2, 1, args); | |
48 t3 = algo(obj1, o3(1), 1, args); | |
49 t4 = algo(obj2, o3(2), 1, args); | |
50 atest = t1 && t2 && t3 && t4; | |
51 % Check the number of outputs | |
52 if numel(o1) ~=1, atest = false; end | |
53 if numel(o2) ~=1, atest = false; end | |
54 if numel(o3) ~=2, atest = false; end | |
55 % Check the rebuilding of the object | |
56 if ~eq(o1, mout1, ple), atest = false; end | |
57 if ~eq(o2, mout2, ple), atest = false; end | |
58 if ~eq(o3, mout3, ple), atest = false; end | |
59 % </AlgoCode> | |
60 else | |
61 atest = false; | |
62 end | |
63 | |
64 % Return a result structure | |
65 result = utp_prepare_result(atest, stest, dbstack, ['utp_' class(obj1) '_' method]); | |
66 end % END UTP_10 |