comparison testing/utp_1.1/utps/rational/utp_rational_rational.m @ 44:409a22968d5e default

Add unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 18:42:11 +0100
parents
children
comparison
equal deleted inserted replaced
43:bc767aaa99a8 44:409a22968d5e
1 % UTP_RATIONAL_RATIONAL a set of UTPs for the rational/rational method
2 %
3 % M Hewitson 06-08-08
4 %
5 % $Id: utp_rational_rational.m,v 1.18 2011/08/22 05:37:13 hewitson Exp $
6 %
7
8 % <MethodDescription>
9 %
10 % The rational method of the rational class constructs RATIONAL objects.
11 %
12 % </MethodDescription>
13
14 function results = utp_rational_rational(varargin)
15
16 % Check the inputs
17 if nargin == 0
18
19 % Some keywords
20 class = 'rational';
21 mthd = 'rational';
22
23 results = [];
24 disp('******************************************************');
25 disp(['**** Running UTPs for ' class '/' mthd]);
26 disp('******************************************************');
27
28 % Test objects
29 [ra1,ra2,ra3,rav,ram] = get_test_objects_rational;
30
31 % Exception list for the UTPs:
32 [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();
33
34 % Run the tests
35 results = [results utp_01]; % getInfo call
36 results = [results utp_02]; % Vector input
37 results = [results utp_03]; % Matrix input
38 results = [results utp_04]; % List input
39 results = [results utp_05]; % Test with mixed input
40 results = [results utp_06]; % Test history is working with empty constructor
41 results = [results utp_07]; % Test history is working with copy constructor
42 results = [results utp_08]; % Test history is working with MAT file constructor
43 results = [results utp_09]; % Test history is working with XML file constructor
44 results = [results utp_10]; % Test history is working with struct constructor
45 results = [results utp_11]; % Test history is working with parfrac-object constructor
46 results = [results utp_12]; % Test history is working with pzmodel-object constructor
47 results = [results utp_13]; % Test history is working with plist(filename) constructor
48 results = [results utp_14]; % Test history is working with plist(hostname) constructor
49 results = [results utp_15]; % Test history is working with plist(den || num) constructor
50 results = [results utp_16]; % Test history is working with plist(pzmodel) constructor
51 results = [results utp_17]; % Test history is working with plist(rational) constructor
52 results = [results utp_18]; % Test history is working with plist(plist) constructor
53 results = [results utp_19]; % Test history is working with conn+Id constructor
54 results = [results utp_20]; % Test history is working with num + den constructor
55 results = [results utp_21]; % Test history is working with num + den + name constructor
56 results = [results utp_22]; % Test history is working with res + poles + dir + name + iunits + ounits constructor
57
58 disp('Done.');
59 disp('******************************************************');
60
61 elseif nargin == 1 % Check for UTP functions
62 if strcmp(varargin{1}, 'isutp')
63 results = 1;
64 elseif strcmpi(varargin{1}, 'needs repository')
65 results = 2;
66 else
67 results = 0;
68 end
69 else
70 error('### Incorrect inputs')
71 end
72
73 %% UTP_01
74
75 % <TestDescription>
76 %
77 % Tests that the getInfo call works for this method.
78 %
79 % </TestDescription>
80 function result = utp_01
81
82
83 % <SyntaxDescription>
84 %
85 % Test that the getInfo call works for no sets, all sets, and each set
86 % individually.
87 %
88 % </SyntaxDescription>
89
90 try
91 % <SyntaxCode>
92 % Call for no sets
93 io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
94 % Call for all sets
95 io(2) = eval([class '.getInfo(''' mthd ''')']);
96 % Call for each set
97 for kk=1:numel(io(2).sets)
98 io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
99 end
100 % </SyntaxCode>
101 stest = true;
102 catch err
103 disp(err.message)
104 stest = false;
105 end
106
107 % <AlgoDescription>
108 %
109 % 1) Check that getInfo call returned an minfo object in all cases.
110 % 2) Check that all plists have the correct parameters.
111 %
112 % </AlgoDescription>
113
114 atest = true;
115 if stest
116 % <AlgoCode>
117 % check we have minfo objects
118 if isa(io, 'minfo')
119 %%% SET 'None'
120 if ~isempty(io(1).sets), atest = false; end
121 if ~isempty(io(1).plists), atest = false; end
122 %%% Check all Sets
123 if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end
124 if ~any(strcmpi(io(2).sets, 'From Pzmodel')), atest = false; end
125 if ~any(strcmpi(io(2).sets, 'From Coefficients')), atest = false; end
126 if ~any(strcmpi(io(2).sets, 'From Repository')), atest = false; end
127 if ~any(strcmpi(io(2).sets, 'From XML File')), atest = false; end
128 if ~any(strcmpi(io(2).sets, 'From MAT File')), atest = false; end
129 if ~any(strcmpi(io(2).sets, 'From Parfrac')), atest = false; end
130 if ~any(strcmpi(io(2).sets, 'From Built-in Model')), atest = false; end
131 if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end
132 %%%%%%%%%% SET 'Default'
133 if io(3).plists.nparams ~= 3, atest = false; end
134 % Check key
135 % Check default value
136 % Check options
137 %%%%%%%%%% SET 'From MAT File'
138 pn = 4;
139 if io(pn).plists.nparams ~= 4, atest = false; end
140 % Check key
141 if ~io(pn).plists.isparam('filename'), atest = false; end
142 % Check default value
143 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end
144 % Check options
145 if ~isequal(io(pn).plists.getOptionsForParam('filename'), {''}), atest = false; end
146 %%%%%%%%%% SET 'From XML File'
147 pn = 5;
148 if io(pn).plists.nparams ~= 4, atest = false; end
149 % Check key
150 if ~io(pn).plists.isparam('filename'), atest = false; end
151 % Check default value
152 if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end
153 % Check options
154 if ~isequal(io(pn).plists.getOptionsForParam('filename'), {''}), atest = false; end
155 %%%%%%%%%% SET 'From Repository'
156 pn = 6;
157 if io(pn).plists.nparams ~= 10, atest = false; end
158 % Check key
159 if ~io(pn).plists.isparam('hostname'), atest = false; end
160 if ~io(pn).plists.isparam('id'), atest = false; end
161 if ~io(pn).plists.isparam('cid'), atest = false; end
162 if ~io(pn).plists.isparam('database'), atest = false; end
163 if ~io(pn).plists.isparam('binary'), atest = false; end
164 if ~io(pn).plists.isparam('username'), atest = false; end
165 if ~io(pn).plists.isparam('password'), atest = false; end
166 % Check default value
167 if ~isEmptyDouble(io(pn).plists.find('id')), atest = false; end
168 if ~isEmptyDouble(io(pn).plists.find('cid')), atest = false; end
169 if ~isequal(io(pn).plists.find('binary'), 'yes'), atest = false; end
170 % Check options
171 if ~isequal(io(pn).plists.getOptionsForParam('id'), {[]}), atest = false; end
172 if ~isequal(io(pn).plists.getOptionsForParam('cid'), {[]}), atest = false; end
173 if ~isequal(io(pn).plists.getOptionsForParam('binary'), {'yes', 'no'}), atest = false; end
174 %%%%%%%%%% SET 'From Built-in Model'
175 pn = 7;
176 if io(pn).plists.nparams ~= 4, atest = false; end
177 % Check key
178 if ~io(pn).plists.isparam('built-in'), atest = false; end
179 % Check default value
180 if ~isEmptyChar(io(pn).plists.find('built-in')), atest = false; end
181 % Check options
182 if ~isequal(io(pn).plists.getOptionsForParam('built-in'), {''}), atest = false; end
183 %%%%%%%%%% SET 'From Pzmodel'
184 pn = 8;
185 if io(pn).plists.nparams ~= 6, atest = false; end
186 % Check key
187 if ~io(pn).plists.isparam('pzmodel'), atest = false; end
188 % Check default value
189 if ~eq(io(pn).plists.find('pzmodel'), pzmodel(), ple1), atest = false; end
190 % Check options
191 %%%%%%%%%% SET 'From Coefficients'
192 pn = 9;
193 if io(pn).plists.nparams ~= 7, atest = false; end
194 % Check key
195 if ~io(pn).plists.isparam('num'), atest = false; end
196 if ~io(pn).plists.isparam('den'), atest = false; end
197 if ~io(pn).plists.isparam('name'), atest = false; end
198 % Check default value
199 if ~isEmptyDouble(io(pn).plists.find('num')), atest = false; end
200 if ~isEmptyDouble(io(pn).plists.find('den')), atest = false; end
201 if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end
202 % Check options
203 if ~isequal(io(pn).plists.getOptionsForParam('num'), {[]}), atest = false; end
204 if ~isequal(io(pn).plists.getOptionsForParam('den'), {[]}), atest = false; end
205 if ~isequal(io(pn).plists.getOptionsForParam('name'), {''}), atest = false; end
206 %%%%%%%%%% SET 'From Parfrac'
207 pn = 10;
208 if io(pn).plists.nparams ~= 6, atest = false; end
209 % Check key
210 if ~io(pn).plists.isparam('parfrac'), atest = false; end
211 % Check default value
212 if ~eq(io(pn).plists.find('parfrac'), parfrac(), ple1), atest = false; end
213 % Check options
214 end
215 % </AlgoCode>
216 else
217 atest = false;
218 end
219
220 % Return a result structure
221 result = utp_prepare_result(atest, stest, dbstack, mfilename);
222 end % END UTP_01
223
224 %% UTP_02
225
226 % <TestDescription>
227 %
228 % Tests that the rational method works with a vector of RATIONAL objects
229 % as input.
230 %
231 % </TestDescription>
232 function result = utp_02
233
234 % <SyntaxDescription>
235 %
236 % Test that the rational method works with a vector of RATIONAL objects
237 % as input.
238 %
239 % </SyntaxDescription>
240
241 try
242 % <SyntaxCode>
243 out = rational(rav);
244 % </SyntaxCode>
245 stest = true;
246 catch err
247 disp(err.message)
248 stest = false;
249 end
250
251 % <AlgoDescription>
252 %
253 % 1) Check that the shape of the output RATIONALs is the same as the
254 % input shape.
255 % 2) Check that each output RATIONAL is a copy of the input RATIONAL.
256 % 3) Check that the copy have an additional history step.
257 %
258 % </AlgoDescription>
259
260 atest = true;
261 if stest
262 % <AlgoCode>
263 % Check we have the correct shape
264 if size(out) ~= size(rav), atest = false; end
265 % Check that the output is a copy.
266 for ii = 1:numel(out)
267 % Check that the output is the same except the history
268 if ~eq(rav(ii), out(ii), ple3), atest = false; end
269 % Check the history
270 if ~eq(rav(ii).hist, out(ii).hist.inhists), atest = false; end
271 % Change the output to make sure that it is a 'real' copy
272 out(ii).setDescription('my desc');
273 if eq(rav(ii), out(ii), ple3), atest = false; end
274 end
275 % </AlgoCode>
276 else
277 atest = false;
278 end
279
280 % Return a result structure
281 result = utp_prepare_result(atest, stest, dbstack, mfilename);
282 end % END UTP_02
283
284 %% UTP_03
285
286 % <TestDescription>
287 %
288 % Tests that the rational method works with a matrix of RATIONAL objects
289 % as input.
290 %
291 % </TestDescription>
292 function result = utp_03
293
294 % <SyntaxDescription>
295 %
296 % Test that the rational method works with a matrix of RATIONAL objects
297 % as input.
298 %
299 % </SyntaxDescription>
300
301 try
302 % <SyntaxCode>
303 out = rational(ram);
304 % </SyntaxCode>
305 stest = true;
306 catch err
307 disp(err.message)
308 stest = false;
309 end
310
311 % <AlgoDescription>
312 %
313 % 1) Check that the shape of the output RATIONALs is the same as the
314 % input shape.
315 % 2) Check that each output RATIONAL is a copy of the input RATIONAL.
316 % 3) Check that the copy have an additional history step.
317 %
318 % </AlgoDescription>
319
320 atest = true;
321 if stest
322 % <AlgoCode>
323 % Check we have the correct number of outputs
324 if size(out) ~= size(ram), atest = false; end
325 % Check that the output is a copy.
326 for ii = 1:numel(out)
327 % Check that the output is the same except the history
328 if ~eq(ram(ii), out(ii), ple3), atest = false; end
329 % Check the history
330 if ~eq(ram(ii).hist, out(ii).hist.inhists), atest = false; end
331 % Change the output to make sure that it is a 'real' copy
332 out(ii).setDescription('my desc');
333 if eq(ram(ii), out(ii), ple3), atest = false; end
334 end
335 % </AlgoCode>
336 else
337 atest = false;
338 end
339
340 % Return a result structure
341 result = utp_prepare_result(atest, stest, dbstack, mfilename);
342 end % END UTP_03
343
344 %% UTP_04
345
346 % <TestDescription>
347 %
348 % Tests that the rational method works with a list of RATIONAL objects as
349 % input.
350 %
351 % </TestDescription>
352 function result = utp_04
353
354 % <SyntaxDescription>
355 %
356 % Test that the rational method works with a list of RATIONAL objects as
357 % input.
358 %
359 % </SyntaxDescription>
360
361 try
362 % <SyntaxCode>
363 out = rational(ra1,ra2,ra3);
364 % </SyntaxCode>
365 stest = true;
366 catch err
367 disp(err.message)
368 stest = false;
369 end
370
371 % <AlgoDescription>
372 %
373 % 1) Check that the number of elements in 'out' is the same of the
374 % number in the input.
375 % 2) Check that each output RATIONAL is a copy of the input RATIONAL.
376 % 3) Check that the copy have an additional history step.
377 %
378 % </AlgoDescription>
379
380 atest = true;
381 pfin = [ra1,ra2,ra3];
382 if stest
383 % <AlgoCode>
384 % Check we have the correct number of outputs
385 if numel(out) ~= 3, atest = false; end
386
387 % Check that the output is a copy.
388 for ii = 1:numel(out)
389 % Check that the output is the same except the history
390 if ~eq(pfin(ii), out(ii), ple3), atest = false; end
391 % Check the history
392 if ~eq(pfin(ii).hist, out(ii).hist.inhists), atest = false; end
393 % Change the output to make sure that it is a 'real' copy
394 out(ii).setDescription('my desc');
395 if eq(pfin(ii), out(ii), ple3), atest = false; end
396 end
397 % </AlgoCode>
398 else
399 atest = false;
400 end
401
402 % Return a result structure
403 result = utp_prepare_result(atest, stest, dbstack, mfilename);
404 end % END UTP_04
405
406 %% UTP_05
407
408 % <TestDescription>
409 %
410 % Tests that the rational method works with a mix of different shaped
411 % RATIONALs as input.
412 %
413 % </TestDescription>
414 function result = utp_05
415
416 % <SyntaxDescription>
417 %
418 % Test that the rational method works with a mix of different shaped
419 % RATIONALs as input.
420 %
421 % </SyntaxDescription>
422
423 try
424 % <SyntaxCode>
425 out = rational(ra1,rav,ra2,ram,ra3);
426 % </SyntaxCode>
427 stest = true;
428 catch err
429 disp(err.message)
430 stest = false;
431 end
432
433 % <AlgoDescription>
434 %
435 % 1) Check that the number of elements in 'out' is the same of the
436 % number in the input.
437 % 2) Check that each output RATIONAL is a copy of the input RATIONAL.
438 % 3) Check that the copy have an additional history step.
439 %
440 % </AlgoDescription>
441
442 atest = true;
443 pfin = [ra1, reshape(rav, 1, []), ra2, reshape(ram, 1, []), ra3];
444 if stest
445 % <AlgoCode>
446 % Check we have the correct number of outputs
447 if numel(out) ~= 3+numel(rav)+numel(ram), atest = false; end
448
449 % Check that the output is a copy.
450 for ii = 1:numel(out)
451 % Check that the output is the same except the history
452 if ~eq(pfin(ii), out(ii), ple3), atest = false; end
453 % Check the history
454 if ~eq(pfin(ii).hist, out(ii).hist.inhists), atest = false; end
455 % Change the output to make sure that it is a 'real' copy
456 out(ii).setDescription('my desc');
457 if eq(pfin(ii), out(ii), ple3), atest = false; end
458 end
459 % </AlgoCode>
460 else
461 atest = false;
462 end
463
464 % Return a result structure
465 result = utp_prepare_result(atest, stest, dbstack, mfilename);
466 end % END UTP_05
467
468 %% UTP_06
469
470 % <TestDescription>
471 %
472 % Tests that the rational method properly applies history.
473 %
474 % </TestDescription>
475 function result = utp_06
476
477 % <SyntaxDescription>
478 %
479 % Test that the result of applying the rational method can be processed
480 % back.
481 %
482 % </SyntaxDescription>
483
484 try
485 % <SyntaxCode>
486 out = rational(ra3);
487 mout = rebuild(out);
488 % </SyntaxCode>
489 stest = true;
490 catch err
491 disp(err.message)
492 stest = false;
493 end
494
495 % <AlgoDescription>
496 %
497 % 1) Check that the last entry in the history of 'out' corresponds to
498 % 'rational'.
499 % 2) Check that the method rebuild produces the same object as 'out'.
500 %
501 % </AlgoDescription>
502
503 atest = true;
504 if stest
505 % <AlgoCode>
506 % Check the last step in the history of 'out'
507 if ~strcmp(out.hist.methodInfo.mname, 'rational'), atest = false; end
508 % Check the rebuilt object
509 if ~eq(mout, out, ple2), atest = false; end
510 % </AlgoCode>
511 else
512 atest = false;
513 end
514
515 % Return a result structure
516 result = utp_prepare_result(atest, stest, dbstack, mfilename);
517 end % END UTP_06
518
519 %% UTP_07
520
521 % <TestDescription>
522 %
523 % Tests that the rational method properly applies history to the copy
524 % constructor.
525 %
526 % </TestDescription>
527 function result = utp_07
528
529 % <SyntaxDescription>
530 %
531 % Test that the output can be processed back with the 'rebuild' method.
532 % Test the constructor with a different number of inputs.
533 %
534 % </SyntaxDescription>
535
536 try
537 % <SyntaxCode>
538 out1 = rational(ra1);
539 out2 = rational(ra1, ra2);
540 out3 = rational(ra1, ra2, ra3);
541 out1.setName('my name');
542 out2(1).setName('my name');
543 out2(2).setName('my name');
544 out3(1).setName('my name');
545 out3(2).setName('my name');
546 out3(3).setName('my name');
547 mout = rebuild(out1);
548 % </SyntaxCode>
549 stest = true;
550 catch err
551 disp(err.message)
552 stest = false;
553 end
554
555 % <AlgoDescription>
556 %
557 % 1) Check that the last entry in the history of 'out' corresponds to
558 % 'rational'.
559 % 2) Check that the original objects are not changed by the setter
560 % function
561 % 3) Check that the method rebuild produces the same object as 'out'.
562 %
563 % </AlgoDescription>
564
565 atest = true;
566 if stest
567 % <AlgoCode>
568 % Check the last step in the history of 'out'
569 % It is the method 'setName' because we set it in above
570 if ~strcmp(out1.hist.methodInfo.mname, 'setName'), atest = false; end
571 % Check next to the last step in the history of 'out'
572 if ~strcmp(out1.hist.inhists.methodInfo.mname, 'rational'), atest = false; end
573 % Check the originals
574 if strcmp(ra1, 'my name'), atest = false; end
575 if strcmp(ra2, 'my name'), atest = false; end
576 if strcmp(ra3, 'my name'), atest = false; end
577 % Check the rebuilt object
578 if ~eq(mout, out1, ple2), atest = false; end
579 % </AlgoCode>
580 else
581 atest = false;
582 end
583
584 % Return a result structure
585 result = utp_prepare_result(atest, stest, dbstack, mfilename);
586 end % END UTP_07
587
588 %% UTP_08
589
590 % <TestDescription>
591 %
592 % Tests that the rational method properly applies history to the read
593 % MAT-file constructor.
594 %
595 % </TestDescription>
596 function result = utp_08
597
598 % <SyntaxDescription>
599 %
600 % Test that the output can be processed back with the 'rebuild' method.
601 %
602 % </SyntaxDescription>
603
604 try
605 % <SyntaxCode>
606 filename = 'ra.mat';
607 ra = rational(ra3);
608 save(ra, filename);
609
610 out = rational(filename);
611 mout = rebuild(out);
612 % </SyntaxCode>
613 stest = true;
614 catch err
615 disp(err.message)
616 stest = false;
617 end
618
619 % <AlgoDescription>
620 %
621 % 1) Check that the 'rebuild' method produces the same object as 'out'.
622 %
623 % </AlgoDescription>
624
625 atest = true;
626 if stest
627 % <AlgoCode>
628 if ~eq(out, ra, ple1), atest = false; end
629 % Check the rebuilt object
630 if ~eq(mout, out, ple1), atest = false; end
631 % </AlgoCode>
632 delete(filename);
633 else
634 atest = false;
635 end
636
637 % Return a result structure
638 result = utp_prepare_result(atest, stest, dbstack, mfilename);
639 end % END UTP_08
640
641
642 %% UTP_09
643
644 % <TestDescription>
645 %
646 % Tests that the rational method properly applies history to the read
647 % XML-file constructor.
648 %
649 % </TestDescription>
650 function result = utp_09
651
652 % <SyntaxDescription>
653 %
654 % Test that the output can be processed back with the 'rebuild' method.
655 %
656 % </SyntaxDescription>
657
658 try
659 % <SyntaxCode>
660 filename = 'ram.xml';
661 amat = rational(ram);
662 save(amat, filename);
663
664 out = rational(filename);
665 mout = rebuild(out);
666 % </SyntaxCode>
667 stest = true;
668 catch err
669 disp(err.message)
670 stest = false;
671 end
672
673 % <AlgoDescription>
674 %
675 % 1) Check that the 'rebuild' method produces the same object as 'out'.
676 %
677 % </AlgoDescription>
678
679 atest = true;
680 if stest
681 % <AlgoCode>
682 % Check the algorithm
683 for kk = 1:numel(out)
684 if ~eq(out(kk), amat(kk), ple1), atest = false; end
685 end
686 % Check the rebuilt object
687 for kk = 1:numel(out)
688 if ~eq(mout(kk), out(kk), ple2), atest = false; end
689 end
690 % </AlgoCode>
691 delete(filename);
692 else
693 atest = false;
694 end
695
696 % Return a result structure
697 result = utp_prepare_result(atest, stest, dbstack, mfilename);
698 end % END UTP_09
699
700 %% UTP_10
701
702 % <TestDescription>
703 %
704 % Tests that the rational method properly doesn't apply history to the
705 % struct constructor.
706 %
707 % </TestDescription>
708 function result = utp_10
709
710 % <SyntaxDescription>
711 %
712 % Test that the output can be processed back with the 'rebuild' method.
713 %
714 % </SyntaxDescription>
715
716 try
717 % <SyntaxCode>
718 sra3 = struct(ra3);
719 sra3.iunits = struct(ra3.iunits);
720 sra3.ounits = struct(ra3.ounits);
721 sra3.hist = struct(ra3.hist);
722
723 out1 = rational(struct(ra2));
724 out2 = rational(sra3);
725 mout1 = rebuild(out1);
726 mout2 = rebuild(out2);
727 % </SyntaxCode>
728 stest = true;
729 catch err
730 disp(err.message)
731 stest = false;
732 end
733
734 % <AlgoDescription>
735 %
736 % 1) Check that the last entry in the history of 'out'
737 % corresponds to 'rational'.
738 % 2) Check that the 'rebuild' method produces the same object as 'out'.
739 %
740 % </AlgoDescription>
741
742 atest = true;
743 if stest
744 % <AlgoCode>
745 % Check that the output is a RATIONAL object
746 if ~isa(out1,'rational'), atest = false; end
747 if ~isa(out2,'rational'), atest = false; end
748 % Check the last step in the history of 'out'
749 if ~strcmp(out1.hist.methodInfo.mname, 'setName'), atest = false; end
750 if ~strcmp(out2.hist.methodInfo.mname, 'setName'), atest = false; end
751 % Check the rebuilt object
752 if ~eq(mout1, out1, ple2), atest = false; end
753 if ~eq(mout2, out2, ple2), atest = false; end
754 % </AlgoCode>
755 else
756 atest = false;
757 end
758
759 % Return a result structure
760 result = utp_prepare_result(atest, stest, dbstack, mfilename);
761 end % END UTP_10
762
763 %% UTP_11
764
765 % <TestDescription>
766 %
767 % Tests that the rational method properly applies history to the parfrac
768 % constructor.
769 %
770 % </TestDescription>
771 function result = utp_11
772
773 % <SyntaxDescription>
774 %
775 % Test that the output can be processed back with the 'rebuild' method.
776 %
777 % </SyntaxDescription>
778
779 try
780 % <SyntaxCode>
781 pf = parfrac([1 2+1i 2-1i], [6 1+3i 1-3i], [1 2 3 4], 'my parfrac', unit('V'), unit('Hz'));
782 out = rational(pf);
783 mout = rebuild(out);
784 % </SyntaxCode>
785 stest = true;
786 catch err
787 disp(err.message)
788 stest = false;
789 end
790
791 % <AlgoDescription>
792 %
793 % 1) Check that the last entry in the history of 'out' corresponds to
794 % 'rational'.
795 % 2) Check that the 'rebuild' method produces the same object as 'out'.
796 %
797 % </AlgoDescription>
798
799 atest = true;
800 if stest
801 % <AlgoCode>
802 % Check that the output is a RATIONAL object
803 if ~isa(out,'rational'), atest = false; end
804 % Check the values of the rationalt object
805 [a,b] = residue(pf.res,pf.poles,pf.dir);
806 if ~isequal(out.num, a), atest = false; end
807 if ~isequal(out.den, b), atest = false; end
808 if ~isequal(out.name, sprintf('rational(%s)', 'my parfrac')), atest = false; end
809 if ~eq(out.iunits, unit('V')), atest = false; end
810 if ~eq(out.ounits, unit('Hz')), atest = false; end
811 % Check the last step in the history of 'out'
812 if ~strcmp(out.hist.methodInfo.mname, 'rational'), atest = false; end
813 if ~strcmp(out.hist.inhists.methodInfo.mname, 'parfrac'), atest = false; end
814 % Check the rebuilt object
815 if ~eq(mout, out, ple2), atest = false; end
816 % </AlgoCode>
817 else
818 atest = false;
819 end
820
821 % Return a result structure
822 result = utp_prepare_result(atest, stest, dbstack, mfilename);
823 end % END UTP_11
824
825 %% UTP_12
826
827 % <TestDescription>
828 %
829 % Tests that the rational method properly applies history to the pzmodel
830 % constructor.
831 %
832 % </TestDescription>
833 function result = utp_12
834
835 % <SyntaxDescription>
836 %
837 % Test that the output can be processed back with the 'rebuild' method.
838 %
839 % </SyntaxDescription>
840
841 try
842 % <SyntaxCode>
843 ps = [pz(1) pz(200) pz(2,4)];
844 zs = [pz(50) pz(2,3)];
845 pzm = pzmodel(1, ps, zs, unit('Hz^2'), unit('V^2'));
846 out = rational(pzm);
847 mout = rebuild(out);
848 % </SyntaxCode>
849 stest = true;
850 catch err
851 disp(err.message)
852 stest = false;
853 end
854
855 % <AlgoDescription>
856 %
857 % 1) Check that the last entry in the history of 'out' corresponds to
858 % 'rational'.
859 % 2) Check that the 'rebuild' method produces the same object as 'out'.
860 %
861 % </AlgoDescription>
862
863 atest = true;
864 if stest
865 % <AlgoCode>
866 % Check that the output is a RATIONAL object
867 if ~isa(out,'rational'), atest = false; end
868 % Check the values of the different proerpties
869 pg = 2*pi*ps(1).f * 2*pi*ps(2).f * 4*pi*pi*ps(3).f*ps(3).f;
870 zg = 2*pi*zs(1).f * 4*pi*pi*zs(2).f*zs(2).f;
871 den = poly(vertcat(pzm.poles(:).ri))./pg;
872 num = pzm.gain.*poly(vertcat(pzm.zeros(:).ri))./zg;
873
874 if ~isequal(out.den, den), atest = false; end
875 if ~isequal(out.num, num), atest = false; end
876 if ~eq(out.iunits, pzm.iunits), atest = false; end
877 if ~eq(out.ounits, pzm.ounits), atest = false; end
878 % Check the last step in the history of 'out'
879 if ~strcmp(out.hist.methodInfo.mname, 'rational'), atest = false; end
880 if ~strcmp(out.hist.inhists.methodInfo.mname, 'pzmodel'), atest = false; end
881 % Check the rebuilt object
882 if ~eq(mout, out, ple2), atest = false; end
883 % </AlgoCode>
884 else
885 atest = false;
886 end
887
888 % Return a result structure
889 result = utp_prepare_result(atest, stest, dbstack, mfilename);
890 end % END UTP_12
891
892 %% UTP_13
893
894 % <TestDescription>
895 %
896 % Tests that the rational method properly applies history to the
897 % plist(filename) constructor.
898 %
899 % </TestDescription>
900 function result = utp_13
901
902 % <SyntaxDescription>
903 %
904 % Test that the output can be processed back to an m-file.
905 %
906 % </SyntaxDescription>
907
908 try
909 % <SyntaxCode>
910 filename1 = 'ra.xml';
911 filename2 = 'ra.mat';
912
913 f1 = rational(ra3);
914 f2 = rational(ra2);
915
916 save(f1, filename1);
917 save(f2, filename2);
918
919 out1 = rational(plist('filename', filename1));
920 out2 = rational(plist('filename', filename2));
921
922 rout1 = out1.rebuild;
923 rout2 = out2.rebuild;
924 % </SyntaxCode>
925 stest = true;
926 catch err
927 disp(err.message)
928 stest = false;
929 end
930
931 % <AlgoDescription>
932 %
933 % 1) Check that the save method doesn't change the input object
934 % 2) Check that the last two entries in the history of 'out'
935 % doesn't corresponds to 'rational' and 'save'
936 % 3) Check that the 'rebuild' method produces the same object as 'out'.
937 %
938 % </AlgoDescription>
939
940 atest = true;
941 if stest
942 % <AlgoCode>
943 % The load object is the same object as the stored object.
944 if ~eq(out1, f1, ple1), atest = false; end
945 if ~eq(out2, f2, ple1), atest = false; end
946 % Rebuild object and check the result
947 if ~eq(rout1, out1, ple2), atest = false; end
948 if ~eq(rout2, out2, ple2), atest = false; end
949 % </AlgoCode>
950 % delete test file
951 delete(filename1)
952 delete(filename2)
953 else
954 atest = false;
955 end
956
957 % Return a result structure
958 result = utp_prepare_result(atest, stest, dbstack, mfilename);
959 end % END UTP_13
960
961 %% UTP_14
962
963 % <TestDescription>
964 %
965 % Tests that the RATIONAL method properly applies history to the
966 % plist(conn) constructor.
967 %
968 % </TestDescription>
969 function result = utp_14
970
971 % <SyntaxDescription>
972 %
973 % Test that the output can be processed back with the rebuild method.
974 %
975 % </SyntaxDescription>
976
977 try
978 % <SyntaxCode>
979 conn = utpGetConnection
980
981 sinfo.conn = conn;
982 sinfo.experiment_title = 'utp_rational_rational_14: submit rational vector';
983 sinfo.experiment_description = 'utp_rational_rational_14: &description';
984 sinfo.analysis_description = '<utp_rational_rational_14>';
985 sinfo.quantity = 'none';
986 sinfo.keywords = 'none';
987 sinfo.reference_ids = '';
988 sinfo.additional_comments = 'none';
989 sinfo.additional_authors = 'no one';
990
991 plForAutoTest = plist('no dialog', true, 'use selector', false);
992 ids = submit(rav, sinfo, plForAutoTest);
993
994 out = rational(plist('hostname', utpGetHostname, 'database', utpGetDatabase, 'conn', conn, 'id', ids));
995 % </SyntaxCode>
996 % Close connection
997 utpCloseConnection(conn);
998 stest = true;
999 catch err
1000 disp(err.message)
1001 % Close connection
1002 utpCloseConnection(conn);
1003 stest = false;
1004 end
1005
1006 % <AlgoDescription>
1007 %
1008 % 1) Check that the last entry in the history of 'out' corresponds to
1009 % 'rational'.
1010 % 2) Check that the 'rebuild' method produces the same object as 'out'.
1011 %
1012 % </AlgoDescription>
1013
1014 atest = true;
1015 if stest
1016 % <AlgoCode>
1017 % Check the last step in the history of 'out'
1018 for kk = 1:numel(out)
1019 if ~strcmp(out(kk).hist.methodInfo.mname, 'rational'), atest = false; end
1020 end
1021 % Check data values
1022 if ~eq(out, rav, ple3), atest = false; end
1023 % Rebuild object and check the result
1024 mout = rebuild(out);
1025 if ~eq(mout, out, ple3), atest = false; end
1026 % </AlgoCode>
1027 else
1028 atest = false;
1029 end
1030
1031 % Return a result structure
1032 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1033 end % END UTP_14
1034
1035 %% UTP_15
1036
1037 % <TestDescription>
1038 %
1039 % Tests that the RATIONAL method properly applies history to the
1040 % plist(den || num) constructor.
1041 %
1042 % </TestDescription>
1043 function result = utp_15
1044
1045 % <SyntaxDescription>
1046 %
1047 % Test that the output can be processed back with the rebuild method.
1048 %
1049 % </SyntaxDescription>
1050
1051 try
1052 % <SyntaxCode>
1053 den = [1 2 3];
1054 num = [4 5 6 7];
1055 name = 'my rational';
1056 iunits = unit('V');
1057 ounits = unit('Hz');
1058 pl = plist('den', den, 'num', num, 'name', name, 'iunits', iunits, 'ounits', ounits);
1059 out = rational(pl);
1060 mout = rebuild(out);
1061 % </SyntaxCode>
1062 stest = true;
1063 catch err
1064 disp(err.message)
1065 stest = false;
1066 end
1067
1068 % <AlgoDescription>
1069 %
1070 % 1) Check that the last entry in the history of 'out' corresponds to
1071 % 'rational'.
1072 % 2) Check that the 'rebuild' method produces the same object as 'out'.
1073 %
1074 % </AlgoDescription>
1075
1076 atest = true;
1077 if stest
1078 % <AlgoCode>
1079 % Check the last step in the history of 'out'
1080 if ~strcmp(out.hist.methodInfo.mname, 'rational'), atest = false; end
1081 % Check the properties
1082 if ~isequal(out.den, den), atest = false; end
1083 if ~isequal(out.num, num), atest = false; end
1084 if ~isequal(out.name, name), atest = false; end
1085 if ~eq(out.iunits, iunits), atest = false; end
1086 if ~eq(out.ounits, ounits), atest = false; end
1087 % Rebuild object and check the result
1088 if ~eq(mout, out, ple2), atest = false; end
1089 % </AlgoCode>
1090 else
1091 atest = false;
1092 end
1093
1094 % Return a result structure
1095 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1096 end % END UTP_15
1097
1098 %% UTP_16
1099
1100 % <TestDescription>
1101 %
1102 % Tests that the RATIONAL method properly applies history to the
1103 % plist(pzmodel) constructor.
1104 %
1105 % </TestDescription>
1106 function result = utp_16
1107
1108 % <SyntaxDescription>
1109 %
1110 % Test that the output can be processed back with the rebuild method.
1111 %
1112 % </SyntaxDescription>
1113
1114 try
1115 % <SyntaxCode>
1116 ps = [pz(1) pz(200)];
1117 zs = pz(50);
1118 pzm = pzmodel(1, ps, zs, unit('Hz'), unit('V'));
1119 pl = plist('pzmodel', pzm);
1120 out = rational(pl);
1121
1122 rout = rebuild(out);
1123 % </SyntaxCode>
1124 stest = true;
1125 catch err
1126 disp(err.message)
1127 stest = false;
1128 end
1129
1130 % <AlgoDescription>
1131 %
1132 % 1) Check that the last entry in the history of 'out' corresponds to
1133 % 'rational'.
1134 % 2) Check that the 'rebuild' method produces the same object as 'out'.
1135 %
1136 % </AlgoDescription>
1137
1138 atest = true;
1139 if stest
1140 % <AlgoCode>
1141 % Check the last step in the history of 'out'
1142 if ~strcmp(out.hist.methodInfo.mname, 'rational'), atest = false; end
1143 % Check the next to the last step in the history.
1144 % It must be the history of the pole/zero model (here 'pzmodel')
1145 if ~strcmp(out.hist.inhists.methodInfo.mname, 'pzmodel'), atest = false; end
1146 % Check values
1147 pg = 2*pi*ps(1).f * 2*pi*ps(2).f;
1148 zg = 2*pi*zs(1).f;
1149 den = poly(vertcat(pzm.poles(:).ri))./pg;
1150 num = pzm.gain.*poly(vertcat(pzm.zeros(:).ri))./zg;
1151
1152 if ~isequal(out.den, den), atest = false; end
1153 if ~isequal(out.num, num), atest = false; end
1154 if ~eq(out.iunits, unit('Hz')), atest = false; end
1155 if ~eq(out.ounits, unit('V')), atest = false; end
1156 % Rebuild object and check the result
1157 if ~eq(rout, out, ple1), atest = false; end
1158 % </AlgoCode>
1159 else
1160 atest = false;
1161 end
1162
1163 % Return a result structure
1164 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1165 end % END UTP_16
1166
1167 %% UTP_17
1168
1169 % <TestDescription>
1170 %
1171 % Tests that the RATIONAL method properly applies history to the
1172 % plist(rational) constructor.
1173 %
1174 % </TestDescription>
1175 function result = utp_17
1176
1177 % <SyntaxDescription>
1178 %
1179 % Test that the output can be processed back with the rebuild method.
1180 %
1181 % </SyntaxDescription>
1182
1183 try
1184 % <SyntaxCode>
1185 pf = parfrac([1 2+1i 2-1i], [6 1+3i 1-3i], [1 2 3 4], 'my parfrac', unit('V'), unit('Hz'));
1186 pl = plist('parfrac', pf);
1187 out = rational(pl);
1188
1189 mout = rebuild(out);
1190 % </SyntaxCode>
1191 stest = true;
1192 catch err
1193 disp(err.message)
1194 stest = false;
1195 end
1196
1197 % <AlgoDescription>
1198 %
1199 % 1) Check that the last entry in the history of 'out' corresponds to
1200 % 'rational'.
1201 % 2) Check that the 'rebuild' method produces the same object as 'out'.
1202 %
1203 % </AlgoDescription>
1204
1205 atest = true;
1206 if stest
1207 % <AlgoCode>
1208 % Check the last step in the history of 'out'
1209 if ~strcmp(out.hist.methodInfo.mname, 'rational'), atest = false; end
1210 % Check the next to the last step in the history.
1211 % It must be the history of the partial fraction model (here 'rational')
1212 if ~strcmp(out.hist.inhists.methodInfo.mname, 'parfrac'), atest = false; end
1213 % Check values
1214 [a,b] = residue(pf.res,pf.poles,pf.dir);
1215 if ~isequal(out.num, a), atest = false; end
1216 if ~isequal(out.den, b), atest = false; end
1217 if ~isequal(out.name, 'rational(my parfrac)'), atest = false; end
1218 if ~eq(out.iunits, unit('V')), atest = false; end
1219 if ~eq(out.ounits, unit('Hz')), atest = false; end
1220 % Rebuild object and check the result
1221 if ~eq(mout, out, ple1), atest = false; end
1222 % </AlgoCode>
1223 else
1224 atest = false;
1225 end
1226
1227 % Return a result structure
1228 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1229 end % END UTP_17
1230
1231 %% UTP_18
1232
1233 % <TestDescription>
1234 %
1235 % Tests that the RATIONAL method properly applies history to the
1236 % plist(<plist-object>) constructor.
1237 %
1238 % </TestDescription>
1239 function result = utp_18
1240
1241 % <SyntaxDescription>
1242 %
1243 % Test that the output can be processed back with the rebuild method.
1244 %
1245 % </SyntaxDescription>
1246
1247 try
1248 % <SyntaxCode>
1249 pf = parfrac([1 2+1i 2-1i], [6 1+3i 1-3i], [1 2 3 4], 'my parfrac', unit('V'), unit('Hz'));
1250 pl = plist('parfrac', pf);
1251 out1 = rational(plist('plist', pl));
1252 out2 = rational(plist('plist', plist())); % empty plist
1253
1254 rout1 = rebuild(out1);
1255 rout2 = rebuild(out2);
1256 % </SyntaxCode>
1257 stest = true;
1258 catch err
1259 disp(err.message)
1260 stest = false;
1261 end
1262
1263 % <AlgoDescription>
1264 %
1265 % 1) Check that the last entry in the history of 'out' corresponds to
1266 % 'rational'.
1267 % 2) Check that the 'rebuild' method produces the same object as 'out'.
1268 %
1269 % </AlgoDescription>
1270
1271 atest = true;
1272 if stest
1273 % <AlgoCode>
1274 % Check the last step in the history of 'out1'
1275 if ~strcmp(out1.hist.methodInfo.mname, 'rational'), atest = false; end
1276 % Check the next to the last step in the history.
1277 % It must be the history of the partial fraction model (here 'rational')
1278 if ~strcmp(out1.hist.inhists.methodInfo.mname, 'parfrac'), atest = false; end
1279 % Check values
1280 if ~eq(out1.iunits, unit('V')), atest = false; end
1281 if ~eq(out1.ounits, unit('Hz')), atest = false; end
1282 % Check the last step in the history of 'out2'
1283 if ~strcmp(out2.hist.methodInfo.mname, 'rational'), atest = false; end
1284 % Check the next to the last step in the history.
1285 if ~isempty(out2.hist.inhists), atest = false; end
1286 % Rebuild object and check the result
1287 if ~eq(rout1, out1, ple1), atest = false; end
1288 if ~eq(rout2, out2, ple1), atest = false; end
1289 % </AlgoCode>
1290 else
1291 atest = false;
1292 end
1293
1294 % Return a result structure
1295 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1296 end % END UTP_18
1297
1298 %% UTP_19
1299
1300 % <TestDescription>
1301 %
1302 % Tests that the RATIONAL method properly applies history to the conn+Id
1303 % constructor.
1304 %
1305 % </TestDescription>
1306 function result = utp_19
1307
1308 % <SyntaxDescription>
1309 %
1310 % Test that the output can be processed back with the rebuild method.
1311 %
1312 % </SyntaxDescription>
1313
1314 try
1315 % <SyntaxCode>
1316 conn = utpGetConnection
1317
1318 sinfo.conn = conn;
1319 sinfo.experiment_title = 'utp_rational_rational_19: submit rational';
1320 sinfo.experiment_description = 'utp_rational_rational_19: description';
1321 sinfo.analysis_description = 'utp_rational_rational_19';
1322 sinfo.quantity = 'none';
1323 sinfo.keywords = 'none';
1324 sinfo.reference_ids = '';
1325 sinfo.additional_comments = 'none';
1326 sinfo.additional_authors = 'no one';
1327
1328 plForAutoTest = plist('no dialog', true, 'use selector', false);
1329 [ids] = submit(ra3, sinfo, plForAutoTest);
1330
1331 out = rational(conn, ids);
1332 % </SyntaxCode>
1333 % Close connection
1334 utpCloseConnection(conn);
1335 stest = true;
1336 catch err
1337 disp(err.message)
1338 % Close connection
1339 utpCloseConnection(conn);
1340 stest = false;
1341 end
1342
1343 % <AlgoDescription>
1344 %
1345 % 1) Check that the last entry in the history of 'out' corresponds to
1346 % 'rational'.
1347 % 2) Check that the 'rebuild' method produces the same object as 'out'.
1348 %
1349 % </AlgoDescription>
1350
1351 atest = true;
1352 if stest
1353 % <AlgoCode>
1354 % Check the last step in the history of 'out'
1355 if ~strcmp(out.hist.methodInfo.mname, 'rational'), atest = false; end
1356 % Check data values
1357 if ~eq(out,ra3, ple3), atest = false; end
1358 % Check the history except the additional 'submit' + 'retrieve' steps
1359 if ~eq(out.hist.inhists, ra3.hist), atest = false; end
1360 % Check the rebuilt object
1361 mout = rebuild(out);
1362 if ~eq(mout, out, ple3), atest = false; end
1363 % </AlgoCode>
1364 else
1365 atest = false;
1366 end
1367
1368 % Return a result structure
1369 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1370 end % END UTP_19
1371
1372 %% UTP_20
1373
1374 % <TestDescription>
1375 %
1376 % Tests that the RATIONAL method properly applies history to the
1377 % num + den object constructor.
1378 %
1379 % </TestDescription>
1380 function result = utp_20
1381
1382 % <SyntaxDescription>
1383 %
1384 % Test that the output can be processed back with the rebuild method.
1385 %
1386 % </SyntaxDescription>
1387
1388 try
1389 % <SyntaxCode>
1390 num = [2 -4 7 -2.5];
1391 den = [1 9 -12];
1392 out = rational(num ,den);
1393
1394 rout = rebuild(out);
1395 % </SyntaxCode>
1396 stest = true;
1397 catch err
1398 disp(err.message)
1399 stest = false;
1400 end
1401
1402 % <AlgoDescription>
1403 %
1404 % 1) Check that the last entry in the history of 'out' corresponds to
1405 % 'rational'.
1406 % 2) Check that the 'rebuild' method produces the same object as 'out'.
1407 %
1408 % </AlgoDescription>
1409
1410 atest = true;
1411 if stest
1412 % <AlgoCode>
1413 % Check the last step in the history of 'out'
1414 if ~strcmp(out.hist.methodInfo.mname, 'rational'), atest = false; end
1415 % Check properties
1416 if ~isequal(out.num, num), atest = false; end
1417 if ~isequal(out.den, den), atest = false; end
1418 % Rebuild object and check the result
1419 if ~eq(rout, out, ple1), atest = false; end
1420 % </AlgoCode>
1421 else
1422 atest = false;
1423 end
1424
1425 % Return a result structure
1426 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1427 end % END UTP_20
1428
1429 %% UTP_21
1430
1431 % <TestDescription>
1432 %
1433 % Tests that the RATIONAL method properly applies history to the
1434 % num + den + name object constructor.
1435 %
1436 % </TestDescription>
1437 function result = utp_21
1438
1439 % <SyntaxDescription>
1440 %
1441 % Test that the output can be processed back with the rebuild method.
1442 %
1443 % </SyntaxDescription>
1444
1445 try
1446 % <SyntaxCode>
1447 num = [2 -4 7 -2.5];
1448 den = [1 9 -12];
1449 name = 'my new crazy name';
1450 out = rational(num, den, name);
1451
1452 rout = rebuild(out);
1453 % </SyntaxCode>
1454 stest = true;
1455 catch err
1456 disp(err.message)
1457 stest = false;
1458 end
1459
1460 % <AlgoDescription>
1461 %
1462 % 1) Check that the last entry in the history of 'out' corresponds to
1463 % 'rational'.
1464 % 2) Check that the 'rebuild' method produces the same object as 'out'.
1465 %
1466 % </AlgoDescription>
1467
1468 atest = true;
1469 if stest
1470 % <AlgoCode>
1471 % Check the last step in the history of 'out'
1472 if ~strcmp(out.hist.methodInfo.mname, 'rational'), atest = false; end
1473 % Check properties
1474 if ~isequal(out.num, num), atest = false; end
1475 if ~isequal(out.den, den), atest = false; end
1476 if ~isequal(out.name, name), atest = false; end
1477 % Rebuild object and check the result
1478 if ~eq(rout, out, ple1), atest = false; end
1479 % </AlgoCode>
1480 else
1481 atest = false;
1482 end
1483
1484 % Return a result structure
1485 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1486 end % END UTP_21
1487
1488 %% UTP_22
1489
1490 % <TestDescription>
1491 %
1492 % Tests that the RATIONAL method properly applies history to the
1493 % num + den + name + iunits + ounits object constructor.
1494 %
1495 % </TestDescription>
1496 function result = utp_22
1497
1498 % <SyntaxDescription>
1499 %
1500 % Test that the output can be processed back with the rebuild method.
1501 %
1502 % </SyntaxDescription>
1503
1504 try
1505 % <SyntaxCode>
1506 num = [2 -4 7 -2.5];
1507 den = [1 9 -12];
1508 name = 'I''m crazy';
1509 iu = unit('V^2');
1510 ou = 's^2/3';
1511 out = rational(num, den, name, iu, ou);
1512
1513 rout = rebuild(out);
1514 % </SyntaxCode>
1515 stest = true;
1516 catch err
1517 disp(err.message)
1518 stest = false;
1519 end
1520
1521 % <AlgoDescription>
1522 %
1523 % 1) Check that the last entry in the history of 'out' corresponds to
1524 % 'rational'.
1525 % 2) Check that the 'rebuild' method produces the same object as 'out'.
1526 %
1527 % </AlgoDescription>
1528
1529 atest = true;
1530 if stest
1531 % <AlgoCode>
1532 % Check the last step in the history of 'out'
1533 if ~strcmp(out.hist.methodInfo.mname, 'rational'), atest = false; end
1534 % Check properties
1535 if ~isequal(out.num, num), atest = false; end
1536 if ~isequal(out.den, den), atest = false; end
1537 if ~isequal(out.name, name), atest = false; end
1538 if ~eq(out.iunits, iu), atest = false; end
1539 if ~eq(out.ounits, unit(ou), ple1), atest = false; end
1540 % Rebuild object and check the result
1541 if ~eq(rout, out, ple1), atest = false; end
1542 % </AlgoCode>
1543 else
1544 atest = false;
1545 end
1546
1547 % Return a result structure
1548 result = utp_prepare_result(atest, stest, dbstack, mfilename);
1549 end % END UTP_22
1550
1551 end