Mercurial > hg > ltpda
comparison testing/utp_1.1/utps/time/utp_time_double.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_TIME_DOUBLE | |
2 % | |
3 % <MethodDescription> | |
4 % | |
5 % Test the 'double' method of the time class. | |
6 % | |
7 % </MethodDescription> | |
8 % | |
9 % $Id: utp_time_double.m,v 1.2 2011/04/28 07:06:27 hewitson Exp $ | |
10 | |
11 function results = utp_time_double(varargin) | |
12 | |
13 % check inputs | |
14 if nargin == 0 | |
15 | |
16 % some keywords | |
17 class = 'time'; | |
18 mthd = 'double'; | |
19 | |
20 results = []; | |
21 disp('******************************************************'); | |
22 disp(['**** Running UTPs for ' class '/' mthd]); | |
23 disp('******************************************************'); | |
24 | |
25 results = [results utp_901]; | |
26 | |
27 disp('Done.'); | |
28 disp('******************************************************'); | |
29 | |
30 elseif nargin == 1 | |
31 % check for UTP functions | |
32 if strcmp(varargin{1}, 'isutp') | |
33 results = 1; | |
34 else | |
35 results = 0; | |
36 end | |
37 else | |
38 error('### Incorrect inputs') | |
39 end | |
40 | |
41 %% UTP_901 | |
42 | |
43 % <TestDescription> | |
44 % | |
45 % Tests 'double' method. | |
46 % | |
47 % </TestDescription> | |
48 function result = utp_901 | |
49 | |
50 % <SyntaxDescription> | |
51 % Use the double() method on single time objects and vectors of time | |
52 % objects. | |
53 % </SyntaxDescription> | |
54 stest = false; | |
55 try | |
56 % <SyntaxCode> | |
57 % construct a well known time object | |
58 t1 = time('1970-01-01 00:00:12.345 UTC'); | |
59 d1 = double(t1); | |
60 t2 = [t1 t1]; | |
61 d2 = double(t2); | |
62 t3 = [t2; t2]; | |
63 d3 = double(t3); | |
64 % </SyntaxCode> | |
65 stest = true; | |
66 end | |
67 | |
68 atest = true; | |
69 try | |
70 % do not run algorithm tests if sintax tests failed | |
71 assert(stest); | |
72 | |
73 % <AlgoDescription> | |
74 % Check that double returns the expected numerical values for each | |
75 % case. | |
76 % </AlgoDescription> | |
77 % <AlgoCode> | |
78 assert(d1 == 12.345); | |
79 assert(all(d2 == 12.345)); | |
80 assert(all(size(d2) == size(t2))); | |
81 assert(all(all(d3 == 12.345))); | |
82 assert(all(size(d3) == size(t3))); | |
83 % </AlgoCode> | |
84 catch | |
85 atest = false; | |
86 end | |
87 | |
88 % return a result structure | |
89 result = utp_prepare_result(atest, stest, dbstack, mfilename); | |
90 end | |
91 | |
92 end |