44
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % UTP_TIME_TIMEZONE
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % <MethodDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % Tests time class 'timezone' static property.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % </MethodDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % NOTE: in this test we manipulate user preferences thus we should make
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % sure we restore the original user preferences at the end of the testing
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % $Id: utp_time_timezone.m,v 1.3 2011/04/28 07:06:27 hewitson Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 function results = utp_time_timezone(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % check 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 = 'time';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 mthd = 'timezone';
|
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 % get preferences
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 prefs = getappdata(0, 'LTPDApreferences');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 oldTimezone = char(prefs.getTimePrefs.getTimeTimezone);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 oldTimeformat = char(prefs.getTimePrefs.getTimestringFormat);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 % get preferences
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 results = [results utp_901];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 results = [results utp_902];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 results = [results utp_903];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 catch ex
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 % restore preferences
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 prefs.getTimePrefs.setTimeTimezone(oldTimezone);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 prefs.getTimePrefs.setTimestringFormat(oldTimeformat);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 rethrow(ex);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 % restore preferences
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 prefs.getTimePrefs.setTimeTimezone(oldTimezone);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 prefs.getTimePrefs.setTimestringFormat(oldTimeformat);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 disp('Done.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 disp('******************************************************');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 elseif nargin == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 % check for UTP functions
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 if strcmp(varargin{1}, 'isutp')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 results = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 results = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 error('### Incorrect inputs')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 %% UTP_901
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 % Tests that the method really returns what is in the user preferences.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 function result = utp_901
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 % Call the static timezone method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 tz = time.timezone;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 stest = true;
|
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 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 % do not run algorithm tests if sintax tests failed
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 assert(stest);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 % Check the resulting timezone object against the one in the user
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 % preferences.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 assert(strcmp(tz.getID(), char(prefs.getTimePrefs.getTimeTimezone)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 catch ex
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 % rethrow(ex)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 % return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 %% UTP_902
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 % Change user preferences and do it again.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 function result = utp_902
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 % Set the timezone in the preferences then call the static timezone method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 prefs.getTimePrefs.setTimeTimezone('GMT-12:00');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 tz = time.timezone;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 % do not run algorithm tests if sintax tests failed
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 assert(stest);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 % Check the resulting timezone object against the one in the user
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 % preferences.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 assert(strcmp(tz.getID(), char(prefs.getTimePrefs.getTimeTimezone)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 catch ex
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 % rethrow(ex)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 % return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 %% UTP_903
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 % <TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 % Change user preferences and do it again.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 % </TestDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 function result = utp_903
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 % <SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 % Set the timezone in the preferences then call the static timezone method.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159 % </SyntaxDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 stest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 % <SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 prefs.getTimePrefs.setTimeTimezone('GMT+06:00');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 tz = time.timezone;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 % </SyntaxCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 stest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 atest = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 % do not run algorithm tests if sintax tests failed
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 assert(stest);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 % <AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 % Check the resulting timezone object against the one in the user
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 % preferences.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 % </AlgoDescription>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 % <AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 assert(strcmp(tz.getID(), char(prefs.getTimePrefs.getTimeTimezone)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 % </AlgoCode>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 atest = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 % return a result structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 result = utp_prepare_result(atest, stest, dbstack, mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 end
|