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