1918
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1447
|
3 |
"{ Package: 'stx:goodies/regression' }"
|
333
|
4 |
|
|
5 |
"{ NameSpace: RegressionTests }"
|
|
6 |
|
|
7 |
TestCase subclass:#TimeDurationTest
|
|
8 |
instanceVariableNames:''
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
1078
|
11 |
category:'tests-Regression-DateAndTime'
|
333
|
12 |
!
|
|
13 |
|
|
14 |
|
|
15 |
!TimeDurationTest methodsFor:'Testing'!
|
|
16 |
|
1919
|
17 |
test_00_Basic
|
|
18 |
|t|
|
|
19 |
|
|
20 |
t := TimeDuration fromSeconds:1.
|
1920
|
21 |
self assert:(t asSeconds = 1).
|
1919
|
22 |
self assert:(t asMilliseconds == 1000).
|
|
23 |
self assert:(t asMicroseconds = 1000000).
|
|
24 |
self assert:(t asNanoseconds = 1000000000).
|
|
25 |
self assert:(t asPicoseconds = 1000000000000).
|
|
26 |
|
1920
|
27 |
t := TimeDuration fromSeconds:1.5.
|
|
28 |
self assert:(t asSeconds = 1).
|
|
29 |
self assert:(t asTruncatedSeconds == 1).
|
|
30 |
self assert:(t asExactSeconds = 1.5).
|
|
31 |
self assert:(t asMilliseconds == 1500).
|
|
32 |
self assert:(t asMicroseconds = 1500000).
|
|
33 |
self assert:(t asNanoseconds = 1500000000).
|
|
34 |
self assert:(t asPicoseconds = 1500000000000).
|
|
35 |
|
1919
|
36 |
t := TimeDuration fromMilliseconds:345.
|
1920
|
37 |
self assert:(t asSeconds = 0).
|
1919
|
38 |
self assert:(t asExactSeconds = 0.345).
|
|
39 |
self assert:(t asTruncatedSeconds = 0).
|
|
40 |
self assert:(t asMilliseconds == 345).
|
|
41 |
self assert:(t asMicroseconds = 345000).
|
|
42 |
self assert:(t asNanoseconds = 345000000).
|
|
43 |
self assert:(t asPicoseconds = 345000000000).
|
|
44 |
|
|
45 |
t := TimeDuration fromMicroseconds:345.
|
|
46 |
self assert:(t asExactSeconds = 0.000345).
|
|
47 |
self assert:(t asTruncatedSeconds = 0).
|
1920
|
48 |
self assert:(t asExactMilliseconds = 0.345).
|
1919
|
49 |
self assert:(t asTruncatedMilliseconds == 0).
|
|
50 |
self assert:(t asMicroseconds = 345).
|
|
51 |
self assert:(t asNanoseconds = 345000).
|
|
52 |
self assert:(t asPicoseconds = 345000000).
|
|
53 |
|
|
54 |
t := TimeDuration fromNanoseconds:345.
|
|
55 |
self assert:(t asExactSeconds = 0.000000345).
|
|
56 |
self assert:(t asTruncatedSeconds = 0).
|
|
57 |
self assert:(t asTruncatedMilliseconds == 0).
|
1920
|
58 |
self assert:(t asExactMilliseconds = 0.000345).
|
1919
|
59 |
self assert:(t asTruncatedMicroseconds = 0).
|
1920
|
60 |
self assert:(t asExactMicroseconds = 0.345).
|
1919
|
61 |
self assert:(t asNanoseconds = 345).
|
|
62 |
self assert:(t asPicoseconds = 345000).
|
|
63 |
|
|
64 |
t := TimeDuration fromPicoseconds:345.
|
|
65 |
self assert:(t asExactSeconds = 0.000000000345).
|
|
66 |
self assert:(t asTruncatedSeconds = 0).
|
1920
|
67 |
self assert:(t asExactMilliseconds = 0.000000345).
|
1919
|
68 |
self assert:(t asTruncatedMilliseconds == 0).
|
1920
|
69 |
self assert:(t asExactMicroseconds = 0.000345).
|
1919
|
70 |
self assert:(t asTruncatedMicroseconds = 0).
|
1920
|
71 |
self assert:(t asExactNanoseconds = 0.345).
|
1919
|
72 |
self assert:(t asTruncatedNanoseconds = 0).
|
|
73 |
self assert:(t asPicoseconds = 345).
|
|
74 |
|
1923
|
75 |
t := TimeDuration fromMicroseconds:-10001.
|
|
76 |
self assert:(t asExactMicroseconds = -10001).
|
|
77 |
|
1926
|
78 |
(4 to:4000000000000000000 byFactor:1000) do:[:v |
|
|
79 |
self assert:(t := TimeDuration new setPicoseconds:v) asPicoseconds = v.
|
|
80 |
self assert:(t := TimeDuration fromPicoseconds:v) asPicoseconds = v.
|
|
81 |
self assert:(t := v picoseconds) asPicoseconds = v.
|
|
82 |
|
|
83 |
self assert:(t := TimeDuration new setNanoseconds:v) asNanoseconds = v.
|
|
84 |
self assert:(t := TimeDuration fromNanoseconds:v) asNanoseconds = v.
|
|
85 |
self assert:(t := v nanoseconds) asNanoseconds = v.
|
|
86 |
|
|
87 |
].
|
|
88 |
|
|
89 |
self assert:(t := 4 picoseconds) printString = ('4ps').
|
|
90 |
self assert:(t := 40 picoseconds) printString = ('40ps').
|
|
91 |
self assert:(t := 400 picoseconds) printString = ('400ps').
|
|
92 |
self assert:(t := 4000 picoseconds) printString = ('4ns').
|
|
93 |
self assert:(4000 picoseconds = 4 nanoseconds).
|
|
94 |
|
|
95 |
self assert:(t := 4 nanoseconds) printString = ('4ns').
|
|
96 |
self assert:(t := 40 nanoseconds) printString = ('40ns').
|
|
97 |
self assert:(t := 400 nanoseconds) printString = ('400ns').
|
1941
|
98 |
self assert:(t := 4000 nanoseconds) printString = ('4µs').
|
1926
|
99 |
self assert:(4000 nanoseconds = 4 microseconds).
|
|
100 |
|
1941
|
101 |
self assert:(t := 4 microseconds) printString = ('4µs').
|
|
102 |
self assert:(t := 40 microseconds) printString = ('40µs').
|
|
103 |
self assert:(t := 400 microseconds) printString = ('400µs').
|
1926
|
104 |
self assert:(t := 4000 microseconds) printString = ('4ms').
|
|
105 |
self assert:(4000 microseconds = 4 milliseconds).
|
|
106 |
|
|
107 |
self assert:(t := 4 milliseconds) printString = ('4ms').
|
|
108 |
self assert:(t := 40 milliseconds) printString = ('40ms').
|
|
109 |
self assert:(t := 400 milliseconds) printString = ('400ms').
|
|
110 |
self assert:(t := 4000 milliseconds) printString = ('4s').
|
|
111 |
self assert:(4000 milliseconds = 4 seconds).
|
1919
|
112 |
"
|
|
113 |
self new test_00_Basic
|
|
114 |
"
|
1941
|
115 |
|
|
116 |
"Modified: / 24-05-2018 / 17:42:49 / Claus Gittinger"
|
1919
|
117 |
!
|
|
118 |
|
1922
|
119 |
test_01_Addition
|
1920
|
120 |
|t1 t2 sum|
|
|
121 |
|
|
122 |
t1 := TimeDuration fromSeconds:1.
|
|
123 |
t2 := TimeDuration fromMilliseconds:1.
|
|
124 |
sum := t1 + t2.
|
|
125 |
|
|
126 |
self assert:(sum asMilliseconds == 1001).
|
|
127 |
self assert:(sum asMicroseconds = 1001000).
|
|
128 |
self assert:(sum asNanoseconds = 1001000000).
|
|
129 |
self assert:(sum asPicoseconds = 1001000000000).
|
|
130 |
|
|
131 |
|
|
132 |
t1 := TimeDuration fromSeconds:1.
|
|
133 |
t2 := TimeDuration fromMicroseconds:1.
|
|
134 |
sum := t1 + t2.
|
|
135 |
|
|
136 |
self assert:(sum asMilliseconds == 1000).
|
|
137 |
self assert:(sum asMicroseconds = 1000001).
|
|
138 |
self assert:(sum asNanoseconds = 1000001000).
|
|
139 |
self assert:(sum asPicoseconds = 1000001000000).
|
|
140 |
|
1921
|
141 |
t1 := TimeDuration fromNanoseconds:100.
|
|
142 |
t2 := TimeDuration fromNanoseconds:15.5.
|
|
143 |
sum := t1 + t2.
|
|
144 |
|
|
145 |
self assert:(sum asNanoseconds = 115).
|
|
146 |
self assert:(sum asPicoseconds = 115500).
|
|
147 |
|
|
148 |
|
|
149 |
"
|
1922
|
150 |
self new test_01_Addition
|
1921
|
151 |
"
|
|
152 |
!
|
|
153 |
|
1922
|
154 |
test_02_Subtraction
|
1921
|
155 |
|t1 t2 sum|
|
|
156 |
|
|
157 |
t1 := TimeDuration fromSeconds:1.
|
|
158 |
t2 := TimeDuration fromMilliseconds:1.
|
|
159 |
sum := t1 - t2.
|
|
160 |
|
|
161 |
self assert:(sum asMilliseconds == 999).
|
|
162 |
self assert:(sum asMicroseconds = 999000).
|
|
163 |
self assert:(sum asNanoseconds = 999000000).
|
|
164 |
self assert:(sum asPicoseconds = 999000000000).
|
|
165 |
|
|
166 |
|
|
167 |
t1 := TimeDuration fromSeconds:1.
|
|
168 |
t2 := TimeDuration fromMicroseconds:1.
|
|
169 |
sum := t1 - t2.
|
|
170 |
|
|
171 |
self assert:(sum asMilliseconds == 999).
|
|
172 |
self assert:(sum asMicroseconds = 999999).
|
|
173 |
self assert:(sum asNanoseconds = 999999000).
|
|
174 |
self assert:(sum asPicoseconds = 999999000000).
|
|
175 |
|
|
176 |
t1 := TimeDuration fromNanoseconds:100.
|
|
177 |
t2 := TimeDuration fromNanoseconds:15.5.
|
|
178 |
sum := t1 - t2.
|
|
179 |
|
|
180 |
self assert:(sum asNanoseconds = 84).
|
|
181 |
self assert:(sum asPicoseconds = 84500).
|
|
182 |
|
1920
|
183 |
|
|
184 |
"
|
1922
|
185 |
self new test_01_Subtraction
|
|
186 |
"
|
|
187 |
!
|
|
188 |
|
|
189 |
test_03_Multiplication
|
|
190 |
|t rslt|
|
|
191 |
|
|
192 |
t := TimeDuration fromSeconds:1.
|
|
193 |
rslt := t * 5.
|
|
194 |
self assert:(rslt asMilliseconds == 5000).
|
|
195 |
self assert:(rslt asPicoseconds = 5000000000000).
|
|
196 |
|
|
197 |
rslt := 5 * t.
|
|
198 |
self assert:(rslt asMilliseconds == 5000).
|
|
199 |
self assert:(rslt asPicoseconds = 5000000000000).
|
|
200 |
|
|
201 |
|
|
202 |
t := TimeDuration fromSeconds:1.1.
|
|
203 |
rslt := t * 2.
|
|
204 |
self assert:(rslt asMilliseconds == 2200).
|
|
205 |
self assert:(rslt asPicoseconds = 2200000000000).
|
|
206 |
|
|
207 |
rslt := 2 * t.
|
|
208 |
self assert:(rslt asMilliseconds == 2200).
|
|
209 |
self assert:(rslt asPicoseconds = 2200000000000).
|
|
210 |
|
|
211 |
|
|
212 |
t := TimeDuration fromNanoseconds:100.
|
|
213 |
rslt := t * 4.5.
|
|
214 |
self assert:(rslt asNanoseconds = 450).
|
|
215 |
self assert:(rslt asPicoseconds = 450000).
|
|
216 |
|
|
217 |
rslt := 4.5 * t.
|
|
218 |
self assert:(rslt asNanoseconds = 450).
|
|
219 |
self assert:(rslt asPicoseconds = 450000).
|
|
220 |
|
|
221 |
|
|
222 |
t := TimeDuration fromMilliseconds:100.
|
|
223 |
t := t + 50 nanoseconds.
|
|
224 |
|
|
225 |
rslt := t * 5.
|
|
226 |
self assert:(rslt asNanoseconds = 500000250).
|
|
227 |
|
|
228 |
rslt := 5 * t.
|
|
229 |
self assert:(rslt asNanoseconds = 500000250).
|
|
230 |
|
|
231 |
|
|
232 |
"
|
|
233 |
self new test_03_Multiplication
|
|
234 |
"
|
|
235 |
!
|
|
236 |
|
|
237 |
test_04_Division
|
|
238 |
|t rslt|
|
|
239 |
|
|
240 |
t := TimeDuration fromSeconds:1.
|
|
241 |
rslt := t / 5.
|
|
242 |
self assert:(rslt asMilliseconds == 200).
|
|
243 |
self assert:(rslt asPicoseconds = 200000000000).
|
|
244 |
|
|
245 |
|
|
246 |
t := TimeDuration fromSeconds:2.2.
|
|
247 |
rslt := t / 2.
|
|
248 |
self assert:(rslt asMilliseconds == 1100).
|
|
249 |
self assert:(rslt asPicoseconds = 1100000000000).
|
|
250 |
|
|
251 |
|
|
252 |
t := TimeDuration fromNanoseconds:450.
|
|
253 |
rslt := t / 4.5.
|
|
254 |
self assert:(rslt asNanoseconds = 100).
|
|
255 |
self assert:(rslt asPicoseconds = 100000).
|
|
256 |
|
|
257 |
|
|
258 |
t := TimeDuration fromMilliseconds:100.
|
|
259 |
t := t + 50 nanoseconds.
|
|
260 |
|
|
261 |
rslt := t / 5.
|
|
262 |
self assert:(rslt asNanoseconds = 20000010).
|
|
263 |
|
|
264 |
|
|
265 |
"
|
|
266 |
self new test_04_Division
|
|
267 |
"
|
|
268 |
!
|
|
269 |
|
|
270 |
test_05_Division
|
|
271 |
"dividing two timeDurations gives a numeric quotient"
|
|
272 |
|
|
273 |
|t1 t2 rslt|
|
|
274 |
|
|
275 |
t1 := TimeDuration fromSeconds:1.
|
|
276 |
t2 := TimeDuration fromSeconds:2.
|
|
277 |
rslt := t1 / t2.
|
|
278 |
self assert:(rslt isNumber).
|
|
279 |
self assert:(rslt = 0.5).
|
|
280 |
|
|
281 |
t1 := TimeDuration fromSeconds:1.
|
|
282 |
t2 := TimeDuration fromMilliseconds:1.
|
|
283 |
rslt := t1 / t2.
|
|
284 |
self assert:(rslt isNumber).
|
|
285 |
self assert:(rslt = 1000).
|
|
286 |
|
|
287 |
t1 := TimeDuration fromMilliseconds:1.
|
|
288 |
t2 := TimeDuration fromMicroseconds:1.
|
|
289 |
rslt := t1 / t2.
|
|
290 |
self assert:(rslt isNumber).
|
|
291 |
self assert:(rslt = 1000).
|
|
292 |
|
|
293 |
t1 := TimeDuration fromMicroseconds:1.
|
|
294 |
t2 := TimeDuration fromNanoseconds:1.
|
|
295 |
rslt := t1 / t2.
|
|
296 |
self assert:(rslt isNumber).
|
|
297 |
self assert:(rslt = 1000).
|
|
298 |
|
|
299 |
t1 := TimeDuration fromSeconds:1.
|
|
300 |
t2 := TimeDuration fromNanoseconds:1.
|
|
301 |
rslt := t1 / t2.
|
|
302 |
self assert:(rslt isNumber).
|
|
303 |
self assert:(rslt = 1000000000).
|
|
304 |
|
|
305 |
t1 := TimeDuration fromSeconds:1.
|
|
306 |
t2 := TimeDuration fromNanoseconds:50.
|
|
307 |
rslt := t1 / t2.
|
|
308 |
self assert:(rslt isNumber).
|
|
309 |
self assert:(rslt = 20000000).
|
|
310 |
|
|
311 |
|
|
312 |
"
|
|
313 |
self new test_05_Division
|
1920
|
314 |
"
|
|
315 |
!
|
|
316 |
|
1923
|
317 |
test_06_miscArithmetic
|
|
318 |
|t rslt|
|
|
319 |
|
|
320 |
t := TimeDuration fromSeconds:1.
|
|
321 |
rslt := t negated.
|
|
322 |
self assert:(rslt asSeconds = -1).
|
|
323 |
self assert:(rslt = (TimeDuration fromSeconds:-1)).
|
|
324 |
|
|
325 |
t := TimeDuration fromMicroseconds:1.
|
|
326 |
rslt := t negated.
|
|
327 |
self assert:(rslt asMicroseconds = -1).
|
|
328 |
self assert:(rslt = (TimeDuration fromMicroseconds:-1)).
|
|
329 |
|
|
330 |
t := TimeDuration fromMicroseconds:10001.
|
|
331 |
rslt := t negated.
|
|
332 |
self assert:(rslt asMicroseconds = -10001).
|
|
333 |
self assert:(rslt = (TimeDuration fromMicroseconds:-10001)).
|
|
334 |
rslt := rslt negated.
|
|
335 |
self assert:(rslt asMicroseconds = 10001).
|
|
336 |
self assert:(rslt = (TimeDuration fromMicroseconds:10001)).
|
|
337 |
|
|
338 |
|
|
339 |
t := TimeDuration fromMicroseconds:-10001.
|
|
340 |
rslt := t abs.
|
|
341 |
self assert:(rslt asMicroseconds = 10001).
|
|
342 |
self assert:(rslt = (TimeDuration fromMicroseconds:10001)).
|
|
343 |
|
|
344 |
"
|
|
345 |
self new test_06_miscArithmetic
|
|
346 |
"
|
|
347 |
!
|
|
348 |
|
|
349 |
test_09_Reading
|
1918
|
350 |
|t1 t2|
|
|
351 |
|
|
352 |
t2 := TimeDuration fromString:'1.001s'.
|
|
353 |
self assert:(t2 asMilliseconds == 1001).
|
|
354 |
|
|
355 |
t1 := TimeDuration fromString:'1001ms'.
|
|
356 |
self assert:(t1 asMilliseconds = 1001).
|
|
357 |
|
|
358 |
t1 := TimeDuration fromString:'1001ns'.
|
|
359 |
self assert:(t1 asNanoseconds = 1001).
|
|
360 |
|
|
361 |
t1 := TimeDuration fromString:'1001us'.
|
|
362 |
self assert:(t1 asMicroseconds = 1001).
|
|
363 |
|
1919
|
364 |
t1 := TimeDuration fromString:'1001ps'.
|
|
365 |
self assert:(t1 asPicoseconds = 1001).
|
|
366 |
|
1918
|
367 |
t1 := TimeDuration fromString:'1s 30us'.
|
|
368 |
self assert:(t1 asMicroseconds = 1000030).
|
|
369 |
|
1920
|
370 |
t1 := TimeDuration fromString:'0.1s'.
|
|
371 |
self assert:(t1 asMilliseconds = 100).
|
|
372 |
t1 := TimeDuration fromString:'0.1ms'.
|
|
373 |
self assert:(t1 asMicroseconds = 100).
|
|
374 |
t1 := TimeDuration fromString:'0.1us'.
|
|
375 |
self assert:(t1 asNanoseconds = 100).
|
|
376 |
t1 := TimeDuration fromString:'0.1ns'.
|
|
377 |
self assert:(t1 asPicoseconds = 100).
|
|
378 |
|
|
379 |
t1 := TimeDuration fromString:'0,1ns'.
|
|
380 |
self assert:(t1 asPicoseconds = 100).
|
|
381 |
|
1918
|
382 |
t1 := TimeDuration fromString:'01:30:33'.
|
|
383 |
self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
|
|
384 |
self assert:(t1 asMilliseconds = (((1*3600)+(30*60)+33)*1000)).
|
|
385 |
|
1920
|
386 |
t1 := TimeDuration fromString:'01:30:33.5'.
|
|
387 |
self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
|
|
388 |
self assert:(t1 asMilliseconds = ((((1*3600)+(30*60)+33)*1000)+500)).
|
|
389 |
|
1918
|
390 |
t1 := TimeDuration fromString:'01:30:33,5'.
|
|
391 |
self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
|
|
392 |
self assert:(t1 asMilliseconds = ((((1*3600)+(30*60)+33)*1000)+500)).
|
|
393 |
|
|
394 |
t1 := TimeDuration fromString:'01:30:33,05'.
|
|
395 |
self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
|
|
396 |
self assert:(t1 asMilliseconds = ((((1*3600)+(30*60)+33)*1000)+50)).
|
|
397 |
|
|
398 |
t1 := TimeDuration fromString:'01:30:33,005'.
|
|
399 |
self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
|
|
400 |
self assert:(t1 asMilliseconds = ((((1*3600)+(30*60)+33)*1000)+5)).
|
|
401 |
|
|
402 |
t1 := TimeDuration fromString:'01:30:33,0005'.
|
|
403 |
self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
|
|
404 |
self assert:(t1 asMicroseconds = ((((1*3600)+(30*60)+33)*1000*1000)+500)).
|
|
405 |
|
|
406 |
t1 := TimeDuration fromString:'01:30:33,00005'.
|
|
407 |
self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
|
|
408 |
self assert:(t1 asMicroseconds = ((((1*3600)+(30*60)+33)*1000*1000)+50)).
|
|
409 |
|
|
410 |
t1 := TimeDuration fromString:'01:30:33,000005'.
|
|
411 |
self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
|
|
412 |
self assert:(t1 asMicroseconds = ((((1*3600)+(30*60)+33)*1000*1000)+5)).
|
|
413 |
|
|
414 |
t1 := TimeDuration fromString:'01:30:33,0000005'.
|
|
415 |
self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
|
|
416 |
self assert:(t1 asNanoseconds = ((((1*3600)+(30*60)+33)*1000*1000*1000)+500)).
|
|
417 |
|
|
418 |
t1 := TimeDuration fromString:'01:30:33,00000005'.
|
|
419 |
self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
|
|
420 |
self assert:(t1 asNanoseconds = ((((1*3600)+(30*60)+33)*1000*1000*1000)+50)).
|
333
|
421 |
|
1918
|
422 |
t1 := TimeDuration fromString:'01:30:33,000000005'.
|
|
423 |
self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
|
|
424 |
self assert:(t1 asNanoseconds = ((((1*3600)+(30*60)+33)*1000*1000*1000)+5)).
|
|
425 |
|
1920
|
426 |
t1 := TimeDuration fromString:'0.000000005'.
|
|
427 |
self assert:(t1 asNanoseconds = 5).
|
1919
|
428 |
|
1920
|
429 |
t1 := TimeDuration fromString:'0.000000005s'.
|
|
430 |
self assert:(t1 asNanoseconds = 5).
|
1919
|
431 |
|
1920
|
432 |
t1 := TimeDuration fromString:'1d 5h'.
|
|
433 |
self assert:(t1 asTruncatedHours = 29).
|
1919
|
434 |
|
1920
|
435 |
t1 := TimeDuration fromString:'1d 5h 30m'.
|
|
436 |
self assert:(t1 asTruncatedHours = 29).
|
|
437 |
self assert:(t1 asExactHours = 29.5).
|
1919
|
438 |
|
|
439 |
"
|
1923
|
440 |
self new test_09_Reading
|
1919
|
441 |
"
|
|
442 |
!
|
|
443 |
|
1918
|
444 |
test_10_PrintingReading
|
|
445 |
#(
|
|
446 |
"/ hours minutes seconds millis
|
|
447 |
(0 0 0 0)
|
|
448 |
(0 0 0 1)
|
|
449 |
(0 0 0 9)
|
|
450 |
(0 0 0 10)
|
|
451 |
(0 0 0 11)
|
|
452 |
(0 0 0 99)
|
|
453 |
(0 0 0 100)
|
|
454 |
(0 0 0 101)
|
|
455 |
(0 0 0 999)
|
|
456 |
(0 0 0 1000)
|
|
457 |
(0 0 0 1001)
|
|
458 |
|
|
459 |
(0 33 0 123)
|
|
460 |
(2 0 0 123)
|
|
461 |
(2 33 0 123)
|
|
462 |
(100 33 0 123)
|
|
463 |
(10000 33 0 123)
|
|
464 |
(1000000 33 0 123)
|
|
465 |
|
|
466 |
(2 33 0 0)
|
|
467 |
(2 0 0 0)
|
|
468 |
(24 0 0 0)
|
|
469 |
(0 0 0 123)
|
333
|
470 |
) do:[:hmsms |
|
1918
|
471 |
|h m s ms d1 d2 s1 s2|
|
333
|
472 |
|
1918
|
473 |
h := hmsms first.
|
|
474 |
m := hmsms second.
|
|
475 |
s := hmsms third.
|
|
476 |
ms := hmsms fourth.
|
|
477 |
"/ generate a duration
|
|
478 |
d1 := TimeDuration hours:h minutes:m seconds:s milliseconds:ms.
|
|
479 |
"/ print it
|
|
480 |
s1 := d1 printString.
|
|
481 |
"/ read it back
|
|
482 |
d2 := TimeDuration readFrom:s1.
|
|
483 |
s2 := d2 printString.
|
|
484 |
"/ same time?
|
|
485 |
self assert:(d1 = d2).
|
|
486 |
self assert:(d1 timeEncoding = d2 timeEncoding).
|
|
487 |
"/ same string?
|
|
488 |
self assert:(s1 = s2).
|
333
|
489 |
].
|
|
490 |
|
|
491 |
|
1447
|
492 |
"/ (TimeDuration hours:0 minutes:0 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
|
|
493 |
"/ (TimeDuration hours:0 minutes:0 seconds:10 milliseconds:123) printStringFormat:'%h:%m:%s'
|
|
494 |
"/ (TimeDuration hours:0 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
|
|
495 |
"/ (TimeDuration hours:2 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
|
|
496 |
"/ (TimeDuration hours:100 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
|
|
497 |
"/ (TimeDuration hours:10000 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
|
|
498 |
"/ (TimeDuration hours:1000000 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
|
333
|
499 |
|
|
500 |
"
|
1918
|
501 |
self new test_10_PrintingReading
|
333
|
502 |
"
|
|
503 |
|
|
504 |
"Created: / 18-07-2007 / 14:02:01 / cg"
|
1925
|
505 |
!
|
|
506 |
|
|
507 |
test_11_Comparing
|
|
508 |
|t1 t2|
|
|
509 |
|
|
510 |
t1 := TimeDuration fromSeconds:1.
|
|
511 |
t2 := t1 + 1 picoseconds.
|
|
512 |
self assert:(t2 > t1).
|
|
513 |
self assert:(t2 >= t1).
|
|
514 |
self assert:(t2 = t1) not.
|
|
515 |
self assert:(t2 <= t1) not.
|
|
516 |
self assert:(t2 < t1) not.
|
|
517 |
|
|
518 |
t1 := TimeDuration fromSeconds:1.
|
|
519 |
t2 := t1 - 1 picoseconds.
|
|
520 |
self assert:(t2 < t1).
|
|
521 |
self assert:(t2 <= t1).
|
|
522 |
self assert:(t2 = t1) not.
|
|
523 |
self assert:(t2 >= t1) not.
|
|
524 |
self assert:(t2 > t1) not.
|
|
525 |
|
|
526 |
"
|
|
527 |
self new test_11_Comparing
|
|
528 |
"
|
333
|
529 |
! !
|
|
530 |
|
|
531 |
!TimeDurationTest class methodsFor:'documentation'!
|
|
532 |
|
|
533 |
version
|
|
534 |
^ '$Header$'
|
1919
|
535 |
!
|
|
536 |
|
|
537 |
version_CVS
|
|
538 |
^ '$Header$'
|
333
|
539 |
! !
|
1078
|
540 |
|