44
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % UTP_PLIST_SAVE a set of UTPs for the plist/save method
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % M Hewitson 06-08-08
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % $Id: utp_plist_save.m,v 1.4 2010/08/31 09:43:48 hewitson Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % <MethodDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % The save method of the plist class saves a plist object to disk. Save stores
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % the variables in a MATLAB formatted file (MAT-file) named filename.mat or in a
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % XML fromat named filename.xml
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % </MethodDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 function results = utp_plist_save(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % Check the inputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 if nargin == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % Some keywords
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 class = 'plist';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 mthd = 'save';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 results = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 disp('******************************************************');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 disp(['**** Running UTPs for ' class '/' mthd]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 disp('******************************************************');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 % Test PLIST objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 [pl1, pl2, pl3, pl4, plv, plm] = get_test_objects_plist;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 % Exception list for the UTPs:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 % Run the tests
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 results = [results utp_01]; % getInfo call
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 results = [results utp_02]; % Vector input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 results = [results utp_03]; % Matrix input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 results = [results utp_04]; % List input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 results = [results utp_05]; % Test with mixed input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 results = [results utp_06]; % Test the modify call works
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 results = [results utp_07]; % Test plist contains the filename
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 disp('Done.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 disp('******************************************************');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 elseif nargin == 1 % Check for UTP functions
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 if strcmp(varargin{1}, 'isutp')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 results = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 results = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 error('### Incorrect inputs')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 %% UTP_01
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 % Tests that the getInfo call works for this method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 function result = utp_01
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 % Test that the getInfo call works for no sets, all sets, and each set
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 % individually.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 % Call for no sets
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 % Call for all sets
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 io(2) = eval([class '.getInfo(''' mthd ''')']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 % Call for each set
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 for kk=1:numel(io(2).sets)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 % 1) Check that getInfo call returned an minfo object in all cases.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 % 2) Check that all plists have the correct parameters.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 % check we have minfo objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 if isa(io, 'minfo')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 %%% SET 'None'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 if ~isempty(io(1).sets), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 if ~isempty(io(1).plists), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 %%% Check all Sets
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 %%%%%%%%%% SET 'Default'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 if io(3).plists.nparams ~= 4, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 if ~io(3).plists.isparam('filename'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 if ~io(3).plists.isparam('prefix'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 if ~io(3).plists.isparam('postfix'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 if ~io(3).plists.isparam('individual files'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 if ~isequal(io(3).plists.find('filename'), ''), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 if ~isequal(io(3).plists.find('prefix'), ''), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 if ~isequal(io(3).plists.find('postfix'), ''), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 if ~isequal(io(3).plists.find('individual files'), false), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 % Check options
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 if ~isequal(io(3).plists.getOptionsForParam('filename'), {[]}), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 end % END UTP_01
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 %% UTP_02
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 % Tests that the save method works with a vector of PLIST objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 function result = utp_02
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 % Test that the save method works for a vector of PLIST objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 % Test both formats 'xml' and 'mat'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 save(plv, 'test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 save(plv, 'test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 out1 = plist('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 out2 = plist('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 % 1) Check that the number of elements in 'out1' and 'out2' are the same
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 % as in 'plv'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 % 2) Check that the loaded objects are the same as the saved objects.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 % 3) The outputs 'out1' and 'out2' must be the same.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 % Check we have the correct number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 if ~isequal(size(out1), size(plv)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 if ~isequal(size(out2), size(plv)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 % Check each output against the input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 for kk=1:numel(out1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 if ~eq(plv(kk), out1(kk), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 if ~eq(plv(kk), out2(kk), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 % Compare the outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 if ~eq(out1, out2, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 delete('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 delete('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 end % END UTP_02
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 %% UTP_03
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 % Tests that the save method works with a matrix of PLIST objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 function result = utp_03
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 % Test that the save method works for a matrix of PLIST objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 % Test both formats 'xml' and 'mat'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 save(plm, 'test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 save(plm, 'test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 out1 = plist('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 out2 = plist('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 % 1) Check that the number of elements in 'out1' and 'out2' are the same
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 % as in 'plm'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 % 2) Check that the loaded objects are the same as the saved objects.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 % 3) The outputs 'out1' and 'out2' must be the same.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 % Check we have the correct number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 if ~isequal(size(out1), size(plm)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 if ~isequal(size(out2), size(plm)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 % Check each output against the input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 for kk=1:numel(out1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 if ~eq(plm(kk), out1(kk), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 if ~eq(plm(kk), out2(kk), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 % Compare the outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 if ~eq(out1, out2, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 delete('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 delete('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 end % END UTP_03
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 %% UTP_04
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 % Tests that the save method works with a list of PLIST objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 function result = utp_04
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 % Test that the save method works for a list of PLIST objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 % Test both formats 'xml' and 'mat'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 save(pl2, pl3, pl4, 'test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 save(pl2, pl3, pl4, 'test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 out1 = plist('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 out2 = plist('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 % 1) Check that the number of elements in 'out1' and 'out2' are the same
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 % as in the list
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 % 2) Check that the loaded objects are the same as the saved objects.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 % 3) The outputs 'out1' and 'out2' must be the same.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 plin = [pl2, pl3, pl4];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 % Check we have the correct number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 if numel(out1) ~= 3, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 if numel(out2) ~= 3, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 % Check each output against the input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 for kk=1:numel(out1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305 if ~eq(plin(kk), out1(kk), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306 if ~eq(plin(kk), out2(kk), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 % Compare the outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 if ~eq(out1, out2, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 delete('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312 delete('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 end % END UTP_04
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 %% UTP_05
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325 % Tests that the save method works with a mix of different shaped PLIST objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 % as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 function result = utp_05
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 % Test that the save method works with an input of matrices and vectors
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 % and single PLIST objects. Test both formats 'xml' and 'mat'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 save(pl2,plv,pl3, 'test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 save(pl2,plv,pl3, 'test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342 out1 = plist('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343 out2 = plist('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 % 1) Check that the number of elements in 'out' is the same as in
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 % input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355 % 2) Check that each output PLIST object contains the correct data.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 plin = [pl2, reshape(plv, 1, []), pl3];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 % Check we have the correct number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364 if numel(out1) ~= 2+numel(plv), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 if numel(out2) ~= 2+numel(plv), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366 % Check each output against the input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367 for kk=1:numel(out1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 if ~eq(plin(kk), out1(kk), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 if ~eq(plin(kk), out2(kk), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 % Compare the outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 if ~eq(out1, out2, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374 delete('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375 delete('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 end % END UTP_05
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 %% UTP_06
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388 % Tests that the save method works with the modify command.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 function result = utp_06
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395 % Use the save method with the modifier command.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401 % copy pl2 to work with
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402 pl = plist(pl2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 pl.save('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404 pl.save('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 out1 = plist('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406 out2 = plist('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416 % 1) Check that the save method doesn't change the input PLIST object.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 % 2) Check the output against the input except.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 % Check that save doesn't modified the input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425 if ~eq(plist(pl2), pl, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 % Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427 if ~eq(pl, out1, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428 if ~eq(pl, out2, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429 % Compare the outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430 if ~eq(out1, out2, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432 delete('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 delete('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440 end % END UTP_06
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442 %% UTP_07
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446 % Control the method with a plist.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 function result = utp_07
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453 % Test that the save method uses the filename which is stored in a plist.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459 pl1 = plist('filename', 'test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460 pl2 = plist('filename', 'test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461 save(pl3, pl1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462 save(pl3, pl2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463 out1 = plist('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464 out2 = plist('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474 % 1) Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481 % Check the output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482 if ~eq(pl3, out1, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483 if ~eq(pl3, out2, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484 % Compare the outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485 if ~eq(out1, out2, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487 delete('test.xml');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488 delete('test.mat');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495 end % END UTP_07
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
497 end
|