Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/ao/utp_ao_min.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_MAX a set of UTPs for the ao/min method | |
2 % | |
3 % M Hewitson 06-08-08 | |
4 % | |
5 % $Id: utp_ao_min.m,v 1.12 2010/06/07 16:43:06 ingo Exp $ | |
6 % | |
7 | |
8 % <MethodDescription> | |
9 % | |
10 % The min method of the ao class computes the smalest element in y- or x- data. | |
11 % | |
12 % </MethodDescription> | |
13 | |
14 function results = utp_ao_min(varargin) | |
15 | |
16 % Check the inputs | |
17 if nargin == 0 | |
18 | |
19 % Some keywords | |
20 class = 'ao'; | |
21 mthd = 'min'; | |
22 | |
23 results = []; | |
24 disp('******************************************************'); | |
25 disp(['**** Running UTPs for ' class '/' mthd]); | |
26 disp('******************************************************'); | |
27 | |
28 % Test AOs | |
29 [at1,at2,at3,at4,at5,at6,atvec,atmat] = eval(['get_test_objects_' class]); | |
30 | |
31 % Overide to include only data2D objects | |
32 atmat = [at1 at5 at2; at2 at1 at6]; | |
33 | |
34 % Exception list for the UTPs: | |
35 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples(); | |
36 | |
37 % Run the tests | |
38 results = [results utp_01]; % getInfo call | |
39 results = [results utp_02(mthd, atvec, @algo_test_y, [], ple3)]; % Vector input | |
40 results = [results utp_03(mthd, atmat, @algo_test_y, [], ple3)]; % Matrix input | |
41 results = [results utp_04(mthd, at1, at2, at3, @algo_test_y, [], ple3)]; % List input | |
42 results = [results utp_05(mthd, at1, atvec, atmat, @algo_test_y, [], ple3)]; % Test with mixed input | |
43 results = [results utp_06(mthd, at1, [], ple2)]; % Test history is working | |
44 results = [results utp_07(mthd, at1, [], ple1)]; % Test the modify call works | |
45 results = [results utp_208(mthd, at1, ple2)]; % Test with additional plist with the key 'axis' | |
46 results = [results utp_09(mthd, at5, at6)]; % Test input data shape == output data shape | |
47 results = [results utp_10(mthd, at5, at6, ple2)]; % Test output of the data | |
48 results = [results utp_11(mthd, at1, ple1)]; % Test plotinfo doesn't disappear | |
49 | |
50 disp('Done.'); | |
51 disp('******************************************************'); | |
52 | |
53 elseif nargin == 1 % Check for UTP functions | |
54 if strcmp(varargin{1}, 'isutp') | |
55 results = 1; | |
56 else | |
57 results = 0; | |
58 end | |
59 else | |
60 error('### Incorrect inputs') | |
61 end | |
62 | |
63 %% Algorithm test for UTP 02,03,04,05 | |
64 | |
65 function atest = algo_test_y(in, out, pli) | |
66 atest = true; | |
67 if ~isequal(min(in.data.getY).', out.data.getY) | |
68 atest = false; | |
69 end | |
70 end | |
71 | |
72 %% UTP_01 | |
73 | |
74 % <TestDescription> | |
75 % | |
76 % Tests that the getInfo call works for this method. | |
77 % | |
78 % </TestDescription> | |
79 function result = utp_01 | |
80 | |
81 | |
82 % <SyntaxDescription> | |
83 % | |
84 % Test that the getInfo call works for no sets, all sets, and each set | |
85 % individually. | |
86 % | |
87 % </SyntaxDescription> | |
88 | |
89 try | |
90 % <SyntaxCode> | |
91 % Call for no sets | |
92 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']); | |
93 % Call for all sets | |
94 io(2) = eval([class '.getInfo(''' mthd ''')']); | |
95 % Call for each set | |
96 for kk=1:numel(io(2).sets) | |
97 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']); | |
98 end | |
99 % </SyntaxCode> | |
100 stest = true; | |
101 catch err | |
102 disp(err.message) | |
103 stest = false; | |
104 end | |
105 | |
106 % <AlgoDescription> | |
107 % | |
108 % 1) Check that getInfo call returned an minfo object in all cases. | |
109 % 2) Check that all plists have the correct parameters. | |
110 % | |
111 % </AlgoDescription> | |
112 | |
113 atest = true; | |
114 if stest | |
115 % <AlgoCode> | |
116 % check we have minfo objects | |
117 if isa(io, 'minfo') | |
118 % SET 'None' | |
119 if ~isempty(io(1).sets), atest = false; end | |
120 if ~isempty(io(1).plists), atest = false; end | |
121 % Check all Sets | |
122 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end | |
123 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end | |
124 % SET 'Default' | |
125 % Check key | |
126 if ~io(3).plists.isparam('axis'), atest = false; end | |
127 if ~io(3).plists.isparam('dim'), atest = false; end | |
128 if ~io(3).plists.isparam('option'), atest = false; end | |
129 % Check default value | |
130 if ~isequal(io(3).plists.find('axis'), 'y'), atest = false; end | |
131 if ~isEmptyDouble(io(3).plists.find('dim')), atest = false; end | |
132 if ~isEmptyChar(io(3).plists.find('option')), atest = false; end | |
133 % Check options | |
134 if ~isequal(io(3).plists.getOptionsForParam('axis'), {'x', 'y', 'xy'}), atest = false; end | |
135 if ~isequal(io(3).plists.getOptionsForParam('dim'), {[]}), atest = false; end | |
136 if ~isequal(io(3).plists.getOptionsForParam('option'), {''}), atest = false; end | |
137 end | |
138 % </AlgoCode> | |
139 else | |
140 atest = false; | |
141 end | |
142 | |
143 % Return a result structure | |
144 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
145 end % END UTP_01 | |
146 | |
147 end |