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