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