Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/ao/utp_ao_plus.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 % UTP_AO_PLUS a set of UTPs for the ao/plus method | |
2 % | |
3 % M Hewitson 06-08-08 | |
4 % | |
5 % $Id: utp_ao_plus.m,v 1.12 2010/09/21 16:51:05 ingo Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The plus method of the ao class computes the sum of the y data of the two | |
11 % inputs. | |
12 % | |
13 % </MethodDescription> | |
14 | |
15 function results = utp_ao_plus(varargin) | |
16 | |
17 % Check the inputs | |
18 if nargin == 0 | |
19 | |
20 % Some keywords | |
21 class = 'ao'; | |
22 mthd = 'plus'; | |
23 | |
24 results = []; | |
25 disp('******************************************************'); | |
26 disp('**** Running UTPs for ao/plus'); | |
27 disp('******************************************************'); | |
28 | |
29 % Run the tests | |
30 results = [results utp_01]; % getInfo call | |
31 results = [results utp_generic_aop_rule1(@plus)]; % Rule 1 | |
32 results = [results utp_generic_aop_rule2(@plus)]; % Rule 2 | |
33 results = [results utp_generic_aop_rule3(@plus)]; % Rule 3 | |
34 results = [results utp_generic_aop_rule4(@plus)]; % Rule 4 | |
35 results = [results utp_generic_aop_rule5(@plus)]; % Rule 5 | |
36 results = [results utp_generic_aop_rule6(@plus)]; % Rule 6 | |
37 results = [results utp_generic_aop_rule7(@plus)]; % Rule 7 | |
38 results = [results utp_generic_aop_rule8(@plus)]; % Rule 8 | |
39 results = [results utp_generic_aop_rule9(@plus)]; % Rule 9 | |
40 results = [results utp_generic_aop_rule10(@plus)]; % Rule 10 | |
41 results = [results utp_generic_aop_rule11(@plus)]; % Rule 11 | |
42 results = [results utp_generic_aop_negative_tests(@plus)]; % Negative tests | |
43 | |
44 disp('Done.'); | |
45 disp('******************************************************'); | |
46 | |
47 elseif nargin == 1 % Check for UTP functions | |
48 if strcmp(varargin{1}, 'isutp') | |
49 results = 1; | |
50 else | |
51 results = 0; | |
52 end | |
53 else | |
54 error('### Incorrect inputs') | |
55 end | |
56 | |
57 %% UTP_01 | |
58 | |
59 % <TestDescription> | |
60 % | |
61 % Tests that the getInfo call works for this method. | |
62 % | |
63 % </TestDescription> | |
64 function result = utp_01 | |
65 | |
66 | |
67 % <SyntaxDescription> | |
68 % | |
69 % Test that the getInfo call works for no sets, all sets, and each set | |
70 % individually. | |
71 % | |
72 % </SyntaxDescription> | |
73 | |
74 try | |
75 % <SyntaxCode> | |
76 % Call for no sets | |
77 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']); | |
78 % Call for all sets | |
79 io(2) = eval([class '.getInfo(''' mthd ''')']); | |
80 % Call for each set | |
81 for kk=1:numel(io(2).sets) | |
82 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']); | |
83 end | |
84 % </SyntaxCode> | |
85 stest = true; | |
86 catch err | |
87 disp(err.message) | |
88 stest = false; | |
89 end | |
90 | |
91 % <AlgoDescription> | |
92 % | |
93 % 1) Check that getInfo call returned an minfo object in all cases. | |
94 % 2) Check that all plists have the correct parameters. | |
95 % | |
96 % </AlgoDescription> | |
97 | |
98 atest = true; | |
99 if stest | |
100 % <AlgoCode> | |
101 % check we have minfo objects | |
102 if isa(io, 'minfo') | |
103 % SET 'None' | |
104 if ~isempty(io(1).sets), atest = false; end | |
105 if ~isempty(io(1).plists), atest = false; end | |
106 % Check all Sets | |
107 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end | |
108 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end | |
109 % SET 'Default' | |
110 if io(3).plists.nparams ~= 0, atest = false; end | |
111 % Check key | |
112 % Check default value | |
113 % Check options | |
114 end | |
115 % </AlgoCode> | |
116 else | |
117 atest = false; | |
118 end | |
119 | |
120 % Return a result structure | |
121 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
122 end % END UTP_01 | |
123 | |
124 end | |
125 |