comparison testing/utp_1.1/utps/ao/utp_ao_exp.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_EXP a set of UTPs for the ao/exp method
2 %
3 % M Hewitson 06-08-08
4 %
5 % $Id: utp_ao_exp.m,v 1.13 2011/04/17 10:48:51 hewitson Exp $
6 %
7
8 % <MethodDescription>
9 %
10 % The exp method of the ao class computes the exponential of the y
11 % and/or x data.
12 %
13 % </MethodDescription>
14
15 function results = utp_ao_exp(varargin)
16
17 % Check the inputs
18 if nargin == 0
19
20 % Some keywords
21 class = 'ao';
22 mthd = 'exp';
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 % 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, [], ple2)]; % 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, at1, at2, 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 %% Algorithm test for UTP 02,03,04,05
62
63 function atest = algo_test_y(in, out, pli)
64 atest = true;
65 if ~isequal(exp(in.data.getY), out.data.getY)
66 atest = false;
67 end
68 end
69
70 %% UTP_01
71
72 % <TestDescription>
73 %
74 % Tests that the getInfo call works for this method.
75 %
76 % </TestDescription>
77 function result = utp_01
78
79
80 % <SyntaxDescription>
81 %
82 % Test that the getInfo call works for no sets, all sets, and each set
83 % individually.
84 %
85 % </SyntaxDescription>
86
87 try
88 % <SyntaxCode>
89 % Call for no sets
90 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
91 % Call for all sets
92 io(2) = eval([class '.getInfo(''' mthd ''')']);
93 % Call for each set
94 for kk=1:numel(io(2).sets)
95 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
96 end
97 % </SyntaxCode>
98 stest = true;
99 catch err
100 disp(err.message)
101 stest = false;
102 end
103
104 % <AlgoDescription>
105 %
106 % 1) Check that getInfo call returned an minfo object in all cases.
107 % 2) Check that all plists have the correct parameters.
108 %
109 % </AlgoDescription>
110
111 atest = true;
112 if stest
113 % <AlgoCode>
114 % check we have minfo objects
115 if isa(io, 'minfo')
116 atest = check_axis_sets(io);
117 end
118 % </AlgoCode>
119 else
120 atest = false;
121 end
122
123 % Return a result structure
124 result = utp_prepare_result(atest, stest, dbstack, mfilename);
125 end % END UTP_01
126
127 end