44
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % UTP_TIMESPAN_TIMESPAN a set of UTPs for the timespan/timespan 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_timespan_timespan.m,v 1.31 2011/09/29 13:46:19 ingo 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 timespan method of the timespan class constructs TIMESPAN objects.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % </MethodDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 function results = utp_timespan_timespan(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % Check the inputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 if nargin == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 % Some keywords
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 class = 'timespan';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 mthd = 'timespan';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 results = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 disp('******************************************************');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 disp(['**** Running UTPs for ' class '/' mthd]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 disp('******************************************************');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 % Test objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 [ts1, ts2, ts3, ts4, ts5, ts6, tsv, tsm] = get_test_objects_timespan;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 % Exception list for the UTPs:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 % get preferences
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 prefs = getappdata(0, 'LTPDApreferences');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 oldTimezone = char(prefs.getTimePrefs.getTimeTimezone);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 oldTimeformat = char(prefs.getTimePrefs.getTimestringFormat);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 % set timezone to UTC for all tests
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 prefs.getTimePrefs.setTimeTimezone('UTC');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 % Run the tests
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 results = [results utp_00];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 results = [results utp_01]; % getInfo call
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 results = [results utp_02]; % Vector input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 results = [results utp_03]; % Matrix input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 results = [results utp_04]; % List input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 results = [results utp_05]; % Test with mixed input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 results = [results utp_06]; % Test history is working with empty constructor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 results = [results utp_07]; % Test history is working with copy constructor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 results = [results utp_08]; % Test history is working with MAT file constructor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 results = [results utp_09]; % Test history is working with XML file constructor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 results = [results utp_10]; % Test history is working with struct constructor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 results = [results utp_11]; % Test history is working with plist(filename) constructor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 results = [results utp_12]; % Test history is working with plist(hostname) constructor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 results = [results utp_13]; % Test history is working with plist(startT+endT) constructor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 results = [results utp_15]; % Test history is working with start + end time constructor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 results = [results utp_16]; % Test history is working with conn+Id constructor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 results = [results utp_17]; % Test history is working with start + end time + format constructor
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 catch ex
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 % restore preferences
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 prefs.getTimePrefs.setTimeTimezone(oldTimezone);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 prefs.getTimePrefs.setTimestringFormat(oldTimeformat);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 disp('Done.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 disp('******************************************************');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 elseif nargin == 1 % Check for UTP functions
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 if strcmp(varargin{1}, 'isutp')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 results = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 elseif strcmpi(varargin{1}, 'needs repository')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 results = 2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 results = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 error('### Incorrect inputs')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 %% UTP_00
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 % Tests that the timespan constructor does what is supposed to do.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 function result = utp_00
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 ts(1) = timespan(1, 2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 ts(end+1) = timespan('00:00:01', '00:00:02');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 ts(end+1) = timespan(time(1), time(2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 ts(end+1) = timespan(plist('startT', 1, 'endT', 2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 ts(end+1) = timespan(plist('startT', '00:00:01', 'endT', '00:00:02'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 ts(end+1) = timespan(plist('startT', time(1), 'endT', time(2)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 ts(end+1) = timespan(plist('startT', '00:00:01', 'endT', '00:00:02'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 ts(end+1) = timespan(plist('startT', '01:00:01', 'endT', '01:00:02', 'timezone', 'CET'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 % do not run algorithm tests if sintax tests failed
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 assert(stest);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 % check that all the start and end time has been interpreted correctly
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 tstart = [ts.startT];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 assert(all([tstart.utc_epoch_milli] == 1000));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 tend = [ts.endT];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 assert(all([tend.utc_epoch_milli] == 2000));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 % return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 %% UTP_01
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 % Tests that the getInfo call works for this method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 function result = utp_01
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 % Test that the getInfo call works for no sets, all sets, and each set
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 % individually.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 % Call for no sets
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 % Call for all sets
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 io(2) = eval([class '.getInfo(''' mthd ''')']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 % Call for each set
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 for kk=1:numel(io(2).sets)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 % 1) Check that getInfo call returned an minfo object in all cases.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 % 2) Check that all plists have the correct parameters.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 % check we have minfo objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 if isa(io, 'minfo')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 %%% SET 'None'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 if ~isempty(io(1).sets), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 if ~isempty(io(1).plists), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 %%% Check all Sets
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 if ~any(strcmpi(io(2).sets, 'From XML File')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 if ~any(strcmpi(io(2).sets, 'From MAT File')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 if ~any(strcmpi(io(2).sets, 'From Repository')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 if ~any(strcmpi(io(2).sets, 'From Timespan Definition')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 if ~any(strcmpi(io(2).sets, 'From Built-in Model')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 %%%%%%%%%% SET 'Default'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 pn = 3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 if io(pn).plists.nparams ~= 3, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 if ~io(pn).plists.isparam('name'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 if ~io(pn).plists.isparam('description'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 %%%%%%%%%% SET 'From MAT File'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 pn = 4;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 if io(pn).plists.nparams ~= 4, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 if ~io(pn).plists.isparam('name'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 if ~io(pn).plists.isparam('description'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 if ~io(pn).plists.isparam('filename'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 %%%%%%%%%% SET 'From XML File'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 pn = 5;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 if io(pn).plists.nparams ~= 4, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 if ~io(pn).plists.isparam('name'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 if ~io(pn).plists.isparam('description'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 if ~io(pn).plists.isparam('filename'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 %%%%%%%%%% SET 'From Repository'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 pn = 6;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 if io(pn).plists.nparams ~= 10, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 if ~io(pn).plists.isparam('name'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 if ~io(pn).plists.isparam('description'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 if ~io(pn).plists.isparam('hostname'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 if ~io(pn).plists.isparam('id'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 if ~io(pn).plists.isparam('cid'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 if ~io(pn).plists.isparam('database'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 if ~io(pn).plists.isparam('binary'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 if ~io(pn).plists.isparam('username'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 if ~io(pn).plists.isparam('password'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 if ~isEmptyDouble(io(pn).plists.find('id')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 if ~isEmptyDouble(io(pn).plists.find('cid')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 if ~isequal(io(pn).plists.find('binary'), 'yes'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 %%%%%%%%%% SET 'From Built-in Model'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 pn = 7;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 if io(pn).plists.nparams ~= 4, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 if ~io(pn).plists.isparam('name'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 if ~io(pn).plists.isparam('description'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 if ~io(pn).plists.isparam('built-in'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 if ~isEmptyChar(io(pn).plists.find('built-in')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 %%%%%%%%%% SET 'From Timespan Definition'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 pn = 8;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 if io(pn).plists.nparams ~= 7, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 % Check key
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 if ~io(pn).plists.isparam('name'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 if ~io(pn).plists.isparam('description'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 if ~io(pn).plists.isparam('plotinfo'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 if ~io(pn).plists.isparam('startt'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 if ~io(pn).plists.isparam('endt'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 if ~io(pn).plists.isparam('timezone'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 if ~io(pn).plists.isparam('timeformat'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 % Check default value
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 if ~isEmptyChar(io(pn).plists.find('description')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270 if ~isEmptyDouble(io(pn).plists.find('plotinfo')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 if ~strcmp(io(pn).plists.find('startt'), ''), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 if ~strcmp(io(pn).plists.find('endt'), ''), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 if ~isequal(io(pn).plists.find('timezone'), 'UTC'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 if ~isequal(io(pn).plists.find('timeformat'), ''), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 end % END UTP_01
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 %% UTP_02
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 % Tests that the timespan method works with a vector of TIMESPAN objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 function result = utp_02
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 % Test that the timespan method works with a vector of TIMESPAN objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 out = timespan(tsv);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312 % 1) Check that the shape of the output TIMESPANs is the same as the input shape.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 % 2) Check that each output TIMESPAN is a copy of the input TIMESPAN.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 % 3) Check that the copy have an additional history step.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 % Check we have the correct shape
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322 if size(out) ~= size(tsv), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 % Check that the output is a copy.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325 for ii = 1:numel(out)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 % Check that the output is the same except the history
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327 if ~eq(tsv(ii), out(ii), ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 % Check the history
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 if ~eq(tsv(ii).hist, out(ii).hist.inhists), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330 % Change the output to make sure that it is a 'real' copy
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 out(ii).setDescription('my desc');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 if eq(tsv(ii), out(ii), ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 end % END UTP_02
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343 %% UTP_03
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 % Tests that the timespan method works with a matrix of TIMESPAN objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 function result = utp_03
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 % Test that the timespan method works with a matrix of TIMESPAN objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 out = timespan(tsm);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 % 1) Check that the shape of the output TIMESPANs is the same as the input shape.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 % 2) Check that each output TIMESPAN is a copy of the input TIMESPAN.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 % 3) Check that the copy have an additional history step.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379 % Check we have the correct number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380 if size(out) ~= size(tsm), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 % Check that the output is a copy.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383 for ii = 1:numel(out)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 % Check that the output is the same except the history
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385 if ~eq(tsm(ii), out(ii), ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 % Check the history
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387 if ~eq(tsm(ii).hist, out(ii).hist.inhists), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388 % Change the output to make sure that it is a 'real' copy
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389 out(ii).setDescription('my desc');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390 if eq(tsm(ii), out(ii), ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 end % END UTP_03
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401 %% UTP_04
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 % Tests that the timespan method works with a list of TIMESPAN objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408 function result = utp_04
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 % Test that the timespan method works with a list of TIMESPAN objects as input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418 out = timespan(ts5, ts4, ts3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428 % 1) Check that the number of elements in 'out' is the same of the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429 % number in the input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430 % 2) Check that each output TIMESPAN is a copy of the input TIMESPAN.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431 % 3) Check that the copy have an additional history step.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436 tsin = [ts5, ts4, ts3];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439 % Check we have the correct number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440 if numel(out) ~= 3, atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442 % Check that the output is a copy.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443 for ii = 1:numel(out)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444 % Check that the output is the same except the history
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445 if ~eq(tsin(ii), out(ii), ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446 % Check the history
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447 if ~eq(tsin(ii).hist, out(ii).hist.inhists), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 % Change the output to make sure that it is a 'real' copy
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 out(ii).setDescription('my desc');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450 if eq(tsin(ii), out(ii), ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459 end % END UTP_04
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461 %% UTP_05
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465 % Tests that the timespan method works with a mix of different shaped TIMESPANs as
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466 % input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469 function result = utp_05
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473 % Test that the timespan method works with a mix of different shaped TIMESPANs as
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474 % input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 out = timespan(ts5,tsv,ts2,tsm,ts4);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490 % 1) Check that the number of elements in 'out' is the same of the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491 % number in the input.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492 % 2) Check that each output TIMESPAN is a copy of the input TIMESPAN.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493 % 3) Check that the copy have an additional history step.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
497 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
498 tsin = [ts5, reshape(tsv, 1, []), ts2, reshape(tsm, 1, []), ts4];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
499 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
500 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
501 % Check we have the correct number of outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
502 if numel(out) ~= 3+numel(tsv)+numel(tsm), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
503
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
504 % Check that the output is a copy.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
505 for ii = 1:numel(out)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
506 % Check that the output is the same except the history
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
507 if ~eq(tsin(ii), out(ii), ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
508 % Check the history
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
509 if ~eq(tsin(ii).hist, out(ii).hist.inhists), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
510 % Change the output to make sure that it is a 'real' copy
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
511 out(ii).setDescription('my desc');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
512 if eq(tsin(ii), out(ii), ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
513 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
514 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
515 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
516 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
517 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
518
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
519 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
520 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
521 end % END UTP_05
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
522
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
523 %% UTP_06
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
524
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
525 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
526 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
527 % Tests that the timespan method properly applies history.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
528 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
529 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
530 function result = utp_06
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
531
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
532 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
533 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
534 % Test that the result of applying the timespan method can be processed back.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
535 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
536 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
537
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
538 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
539 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
540 out = timespan(ts4);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
541 mout = rebuild(out);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
542 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
543 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
544 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
545 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
546 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
547 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
548
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
549 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
550 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
551 % 1) Check that the last entry in the history of 'out' corresponds to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
552 % 'timespan'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
553 % 2) Check that the method rebuild produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
554 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
555 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
556
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
557 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
558 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
559 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
560 % Check the last step in the history of 'out'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
561 if ~strcmp(out.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
562 % Check the rebuilt object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
563 if ~eq(mout, out, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
564 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
565 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
566 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
567 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
568
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
569 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
570 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
571 end % END UTP_06
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
572
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
573 %% UTP_07
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
574
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
575 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
576 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
577 % Tests that the timespan method properly applies history to the copy constructor.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
578 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
579 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
580 function result = utp_07
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
581
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
582 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
583 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
584 % Test that the output can be processed back with the 'rebuild' method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
585 % Test the constructor with a different number of inputs.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
586 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
587 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
588
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
589 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
590 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
591 out1 = timespan(ts5);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
592 out2 = timespan(ts5, ts4);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
593 out3 = timespan(ts5, ts4, ts3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
594 out1.setName('my name');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
595 out2(1).setName('my name');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
596 out2(2).setName('my name');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
597 out3(1).setName('my name');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
598 out3(2).setName('my name');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
599 out3(3).setName('my name');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
600 mout = rebuild(out1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
601 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
602 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
603 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
604 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
605 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
606 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
607
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
608 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
609 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
610 % 1) Check that the last entry in the history of 'out' corresponds to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
611 % 'timespan'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
612 % 2) Check that the original objects are not changed by the setter function
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
613 % 3) Check that the method rebuild produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
614 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
615 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
616
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
617 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
618 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
619 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
620 % Check the last step in the history of 'out'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
621 % It is the method 'setName' because we set it in above
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
622 if ~strcmp(out1.hist.methodInfo.mname, 'setName'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
623 % Check next to the last step in the history of 'out'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
624 if ~strcmp(out1.hist.inhists.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
625 % Check the originals
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
626 if strcmp(ts5, 'my name'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
627 if strcmp(ts4, 'my name'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
628 if strcmp(ts3, 'my name'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
629 % Check the rebuilt object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
630 if ~eq(mout, out1, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
631 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
632 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
633 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
634 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
635
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
636 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
637 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
638 end % END UTP_07
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
639
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
640 %% UTP_08
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
641
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
642 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
643 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
644 % Tests that the timespan method properly applies history to the read
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
645 % MAT-file constructor.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
646 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
647 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
648 function result = utp_08
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
649
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
650 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
651 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
652 % Test that the output can be processed back with the 'rebuild' method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
653 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
654 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
655
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
656 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
657 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
658 filename = 'test_ts.mat';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
659 ts = timespan(ts4);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
660 save(ts, filename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
661
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
662 out = timespan(filename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
663 mout = rebuild(out);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
664 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
665 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
666 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
667 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
668 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
669 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
670
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
671 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
672 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
673 % 1) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
674 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
675 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
676
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
677 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
678 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
679 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
680 if ~eq(out, ts, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
681 % Check the rebuilt object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
682 if ~eq(mout, out, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
683 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
684 delete(filename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
685 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
686 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
687 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
688
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
689 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
690 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
691 end % END UTP_08
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
692
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
693
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
694 %% UTP_09
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
695
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
696 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
697 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
698 % Tests that the timespan method properly applies history to the read
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
699 % XML-file constructor.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
700 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
701 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
702 function result = utp_09
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
703
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
704 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
705 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
706 % Test that the output can be processed back with the 'rebuild' method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
707 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
708 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
709
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
710 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
711 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
712 filename = 'test_ts.xml';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
713 amat = timespan(tsm);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
714 save(amat, filename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
715
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
716 out = timespan(filename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
717 mout = rebuild(out);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
718 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
719 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
720 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
721 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
722 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
723 rethrow(err);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
724 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
725
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
726 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
727 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
728 % 1) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
729 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
730 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
731
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
732 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
733 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
734 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
735 % Check the algorithm
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
736 for kk = 1:numel(out)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
737 if ~eq(out(kk), amat(kk), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
738 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
739
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
740 % Check the rebuilt object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
741 for kk = 1:numel(out)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
742 if ~eq(mout(kk), out(kk), ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
743 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
744 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
745 delete(filename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
746 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
747 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
748 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
749
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
750 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
751 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
752 end % END UTP_09
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
753
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
754 %% UTP_10
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
755
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
756 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
757 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
758 % Tests that the timespan method properly applies history to the struct constructor.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
759 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
760 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
761 function result = utp_10
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
762
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
763 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
764 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
765 % Test that the output can be processed back with the 'rebuild' method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
766 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
767 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
768
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
769 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
770 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
771 % silence warnings about converting objects to struct
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
772 w = warning('off', 'MATLAB:structOnObject');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
773
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
774 sts5 = struct(ts5);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
775 sts5.startT = struct(ts5.startT);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
776 sts5.endT = struct(ts5.endT);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
777 sts5.hist = struct(ts5.hist);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
778
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
779 out1 = timespan(struct(ts5));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
780 out2 = timespan(sts5);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
781 mout1 = rebuild(out1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
782 mout2 = rebuild(out2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
783
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
784 % restore warnings
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
785 warning(w);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
786 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
787 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
788 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
789 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
790 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
791 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
792
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
793 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
794 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
795 % 1) Check that the last entry in the history of 'out'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
796 % corresponds to 'timespan'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
797 % 2) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
798 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
799 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
800
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
801 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
802 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
803 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
804 % Check that the output is a TIMESPAN object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
805 if ~isa(out1,'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
806 if ~isa(out2,'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
807 % Check the last step in the history of 'out'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
808 if ~strcmp(out1.hist.methodInfo.mname, 'setName'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
809 if ~strcmp(out2.hist.methodInfo.mname, 'setName'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
810 % Check the rebuilt object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
811 if ~eq(mout1, out1, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
812 if ~eq(mout2, out2, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
813 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
814 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
815 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
816 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
817
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
818 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
819 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
820 end % END UTP_10
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
821
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
822 %% UTP_11
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
823
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
824 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
825 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
826 % Tests that the timespan method properly applies history to the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
827 % plist(filename) constructor.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
828 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
829 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
830 function result = utp_11
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
831
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
832 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
833 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
834 % Test that the output can be processed back to an m-file.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
835 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
836 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
837
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
838 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
839 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
840 filename1 = 'test_ts.xml';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
841 filename2 = 'test_ts.mat';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
842
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
843 f1 = timespan(ts5);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
844 f2 = timespan(ts4);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
845
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
846 save(f1, filename1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
847 save(f2, filename2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
848
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
849 out1 = timespan(plist('filename', filename1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
850 out2 = timespan(plist('filename', filename2));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
851
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
852 mout1 = out1.rebuild;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
853 mout2 = out2.rebuild;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
854
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
855 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
856 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
857 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
858 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
859 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
860 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
861
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
862 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
863 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
864 % 1) Check that the save method doesn't change the input object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
865 % 2) Check that the last two entries in the history of 'out' corresponds to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
866 % 'timespan' and 'save'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
867 % 3) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
868 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
869 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
870
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
871 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
872 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
873 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
874 % Check the input object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
875 if ~eq(f1, timespan(ts5), ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
876 if ~eq(f2, timespan(ts4), ple1) , atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
877 % The load doesn't have two additionally history steps (save + load)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
878 if ~eq(out1, f1, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
879 if ~eq(out2, f2, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
880 % Rebuild object and check the result
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
881 if ~eq(mout1, out1, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
882 if ~eq(mout2, out2, ple2), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
883 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
884 % delete test file
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
885 delete(filename1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
886 delete(filename2)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
887 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
888 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
889 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
890
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
891 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
892 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
893 end % END UTP_11
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
894
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
895 %% UTP_12
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
896
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
897 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
898 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
899 % Tests that the TIMESPAN method properly applies history to the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
900 % plist(conn) constructor.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
901 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
902 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
903 function result = utp_12
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
904
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
905 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
906 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
907 % Test that the output can be processed back with the rebuild method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
908 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
909 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
910
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
911 conn = utpGetConnection
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
912 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
913 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
914
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
915 sinfo.conn = conn;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
916 sinfo.experiment_title = 'utp_timespan_timespan_12: submit timespan vector';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
917 sinfo.experiment_description = 'utp_timespan_timespan_12: &description';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
918 sinfo.analysis_description = '<utp_timespan_timespan_12>';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
919 sinfo.quantity = 'none';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
920 sinfo.keywords = 'none';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
921 sinfo.reference_ids = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
922 sinfo.additional_comments = 'none';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
923 sinfo.additional_authors = 'no one';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
924
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
925 plForAutoTest = plist('no dialog', true, 'use selector', false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
926 ids = submit(tsv, sinfo, plForAutoTest);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
927
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
928 out = timespan(plist('hostname', utpGetHostname, 'database', utpGetDatabase, 'conn', conn, 'id', ids));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
929 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
930 utpCloseConnection(conn);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
931 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
932 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
933 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
934 % Close connection
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
935 utpCloseConnection(conn);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
936 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
937 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
938
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
939 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
940 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
941 % 1) Check that the last entry in the history of 'out' corresponds to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
942 % 'timespan'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
943 % 2) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
944 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
945 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
946
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
947 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
948 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
949 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
950 % Check the last step in the history of 'out'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
951 for kk = 1:numel(out)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
952 if ~strcmp(out(kk).hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
953 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
954 % Check data values
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
955 if ~eq(out, tsv, ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
956 % Rebuild object and check the result
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
957 mout = rebuild(out);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
958 if ~eq(mout, out, ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
959 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
960 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
961 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
962 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
963
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
964 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
965 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
966 end % END UTP_12
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
967
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
968 %% UTP_13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
969
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
970 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
971 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
972 % Tests that the TIMESPAN method properly applies history to the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
973 % plist(type) constructor.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
974 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
975 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
976 function result = utp_13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
977
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
978 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
979 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
980 % Test that the output can be processed back with the rebuild method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
981 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
982 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
983
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
984 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
985 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
986 tf = 'HH:MM:SS.FFF';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
987 tz = 'GMT-04';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
988 pl1 = plist('startT', time(1), 'endT', 2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
989 pl2 = plist('startT', '00:01:00.000', 'endT', '00:02:00.000', 'timezone', tz);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
990 pl3 = plist('startT', '00:00:00.000', 'endT', 2, 'timeformat', tf);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
991
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
992 out1 = timespan(pl1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
993 out2 = timespan(pl2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
994 out3 = timespan(pl3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
995
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
996 mout1 = rebuild(out1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
997 mout2 = rebuild(out2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
998 mout3 = rebuild(out3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
999 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1000 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1001 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1002 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1003 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1004 % rethrow(err)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1005 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1006
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1007 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1008 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1009 % 1) Check that the last entry in the history of 'out' corresponds to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1010 % 'timespan'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1011 % 2) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1012 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1013 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1014
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1015 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1016 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1017 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1018 % Check the last step in the history of 'out'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1019 if ~strcmp(out1.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1020 if ~strcmp(out2.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1021 if ~strcmp(out3.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1022 % Check first plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1023 if ~eq(out1.startT, time(1)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1024 if ~eq(out1.endT, time(2)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1025 % Check second plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1026 if ~eq(out2.startT, time(plist('time', '00:01:00', 'timezone', tz))), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1027 if ~eq(out2.endT, time(plist('time', '00:02:00', 'timezone', tz))), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1028 % Check third plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1029 if ~eq(out3.startT, time(0)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1030 if ~eq(out3.endT, time(2)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1031 % Rebuild object and check the result
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1032 if ~eq(mout1, out1, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1033 if ~eq(mout2, out2, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1034 if ~eq(mout3, out3, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1035 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1036 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1037 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1038 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1039
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1040 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1041 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1042 end % END UTP_13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1043
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1044
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1045 %% UTP_15
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1046
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1047 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1048 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1049 % Tests that the TIMESPAN method properly applies history to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1050 % the start + end time constructor.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1051 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1052 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1053 function result = utp_15
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1054
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1055 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1056 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1057 % Test that the output can be processed back with the rebuild method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1058 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1059 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1060
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1061 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1062 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1063 out1 = timespan('14:00:00', '14:00:05');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1064 out2 = timespan('00:00:01', time(4));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1065 out3 = timespan(time(1234), time(2345));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1066 out4 = timespan(time(1.234), '00:00:05');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1067
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1068 mout1 = rebuild(out1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1069 mout2 = rebuild(out2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1070 mout3 = rebuild(out3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1071 mout4 = rebuild(out4);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1072 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1073 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1074 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1075 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1076 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1077 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1078
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1079 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1080 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1081 % 1) Check that the last entry in the history of 'out' corresponds to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1082 % 'timespan'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1083 % 2) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1084 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1085 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1086
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1087 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1088 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1089 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1090 % Check the last step in the history of 'out'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1091 if ~strcmp(out1.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1092 if ~strcmp(out2.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1093 if ~strcmp(out3.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1094 if ~strcmp(out4.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1095 % Check values
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1096 if ~eq(out1.startT, time('14:00:00')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1097 if ~eq(out1.endT, time('14:00:05')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1098 if ~eq(out2.startT, time('00:00:01')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1099 if ~eq(out2.endT, time(4)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1100 if ~eq(out3.startT, time(1234)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1101 if ~eq(out3.endT, time(2345)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1102 if ~eq(out4.startT, time(1.234)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1103 if ~eq(out4.endT, time('00:00:05')), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1104 % Rebuild object and check the result
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1105 if ~eq(mout1, out1, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1106 if ~eq(mout2, out2, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1107 if ~eq(mout3, out3, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1108 if ~eq(mout4, out4, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1109 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1110 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1111 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1112 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1113
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1114 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1115 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1116 end % END UTP_15
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1117
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1118 %% UTP_16
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1119
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1120 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1121 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1122 % Tests that the TIMESPAN method properly applies history to the conn+Id constructor.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1123 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1124 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1125 function result = utp_16
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1126
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1127 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1128 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1129 % Test that the output can be processed back with the rebuild method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1130 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1131 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1132
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1133 conn = utpGetConnection
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1134 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1135 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1136
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1137 sinfo.conn = conn;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1138 sinfo.experiment_title = 'utp_timespan_timespan_16: submit timespan';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1139 sinfo.experiment_description = 'utp_timespan_timespan_16: description';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1140 sinfo.analysis_description = 'utp_timespan_timespan_16';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1141 sinfo.quantity = 'none';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1142 sinfo.keywords = 'none';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1143 sinfo.reference_ids = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1144 sinfo.additional_comments = 'none';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1145 sinfo.additional_authors = 'no one';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1146
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1147 plForAutoTest = plist('no dialog', true, 'use selector', false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1148 [ids] = submit(ts4, sinfo, plForAutoTest);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1149
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1150 out = timespan(conn, ids);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1151 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1152 utpCloseConnection(conn);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1153 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1154 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1155 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1156 % Close connection
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1157 utpCloseConnection(conn);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1158 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1159 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1160
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1161 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1162 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1163 % 1) Check that the last entry in the history of 'out' corresponds to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1164 % 'timespan'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1165 % 2) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1166 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1167 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1168
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1169 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1170 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1171 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1172 % Check the last step in the history of 'out'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1173 if ~strcmp(out.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1174 % Check data values
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1175 if ~eq(out,ts4, ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1176 % Check the history except the additional 'submit' + 'retrieve' steps
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1177 if ~eq(out.hist.inhists, ts4.hist), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1178 % Rebuild object and check the result
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1179 mout = rebuild(out);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1180 if ~eq(mout, out, ple3), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1181 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1182 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1183 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1184 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1185
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1186 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1187 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1188 end % END UTP_16
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1189
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1190 %% UTP_17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1191
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1192 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1193 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1194 % Tests that the TIMESPAN method properly applies history to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1195 % the start + end time + format constructor.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1196 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1197 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1198 function result = utp_17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1199
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1200 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1201 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1202 % Test that the output can be processed back with the rebuild method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1203 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1204 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1205
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1206 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1207 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1208 f1 = 'HH:MM:SS';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1209 f2 = 'HH:MM:SS';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1210 f4 = 'HH:MM:SS';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1211 out1 = timespan('14:00:00', '14:00:05', f1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1212 out2 = timespan('00:00:01', time(4), f2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1213 out3 = timespan(time(1.234), time(2.345));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1214 out4 = timespan(time(1.234), '00:00:05', f4);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1215
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1216 mout1 = rebuild(out1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1217 mout2 = rebuild(out2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1218 mout3 = rebuild(out3);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1219 mout4 = rebuild(out4);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1220 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1221 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1222 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1223 disp(err.message)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1224 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1225 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1226
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1227 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1228 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1229 % 1) Check that the last entry in the history of 'out' corresponds to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1230 % 'timespan'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1231 % 2) Check that the 'rebuild' method produces the same object as 'out'.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1232 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1233 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1234
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1235 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1236 if stest
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1237 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1238 % Check the last step in the history of 'out'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1239 if ~strcmp(out1.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1240 if ~strcmp(out2.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1241 if ~strcmp(out3.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1242 if ~strcmp(out4.hist.methodInfo.mname, 'timespan'), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1243 % Check first object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1244 if ~eq(out1.startT, time('14:00:00', f1)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1245 if ~eq(out1.endT, time('14:00:05', f1)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1246 % Check second object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1247 if ~eq(out2.startT, time('00:00:01', f2)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1248 if ~eq(out2.endT, time(4.000)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1249 % Check third object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1250 if ~eq(out3.startT, time(1.234)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1251 if ~eq(out3.endT, time(2.345)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1252 % Check fourth object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1253 if ~eq(out4.startT, time(1.234)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1254 if ~eq(out4.endT, time('00:00:05', f4)), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1255 % Rebuild object and check the result
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1256 if ~eq(mout1, out1, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1257 if ~eq(mout2, out2, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1258 if ~eq(mout3, out3, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1259 if ~eq(mout4, out4, ple1), atest = false; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1260 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1261 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1262 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1263 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1264
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1265 % Return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1266 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1267 end % END UTP_17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1268
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1269 end
|