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