comparison base/test/TestOurRealTime.h @ 1262:c4f873749ab5 3.0-integration

RealTime fixes to comply with new, more demanding tests; also run same (failing) tests on Vamp SDK version
author Chris Cannam
date Tue, 15 Nov 2016 16:12:48 +0000
parents
children abfc498c52bc
comparison
equal deleted inserted replaced
1261:968d54d893d2 1262:c4f873749ab5
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. See the file
12 COPYING included with this distribution for more information.
13 */
14
15 #ifndef TEST_OUR_REALTIME_H
16 #define TEST_OUR_REALTIME_H
17
18 #include <QObject>
19 #include <QtTest>
20 #include <QDir>
21
22 #include <iostream>
23
24 #include "../RealTime.h"
25
26 using namespace std;
27
28 #define ONE_MILLION 1000000
29 #define ONE_BILLION 1000000000
30
31 class TestOurRealTime : public QObject
32 {
33 Q_OBJECT
34
35 void compareTexts(string s, const char *e) {
36 QCOMPARE(QString(s.c_str()), QString(e));
37 }
38
39 typedef sv_frame_t frame_type;
40
41 private slots:
42
43 void zero()
44 {
45 QCOMPARE(RealTime(0, 0), RealTime::zeroTime);
46 QCOMPARE(RealTime(0, 0).sec, 0);
47 QCOMPARE(RealTime(0, 0).nsec, 0);
48 QCOMPARE(RealTime(0, 0).msec(), 0);
49 QCOMPARE(RealTime(0, 0).usec(), 0);
50 }
51
52 void ctor()
53 {
54 QCOMPARE(RealTime(0, 0), RealTime(0, 0));
55
56 // wraparounds
57 QCOMPARE(RealTime(0, ONE_BILLION/2), RealTime(1, -ONE_BILLION/2));
58 QCOMPARE(RealTime(0, -ONE_BILLION/2), RealTime(-1, ONE_BILLION/2));
59
60 QCOMPARE(RealTime(1, ONE_BILLION), RealTime(2, 0));
61 QCOMPARE(RealTime(1, -ONE_BILLION), RealTime(0, 0));
62 QCOMPARE(RealTime(-1, ONE_BILLION), RealTime(0, 0));
63 QCOMPARE(RealTime(-1, -ONE_BILLION), RealTime(-2, 0));
64
65 QCOMPARE(RealTime(2, -ONE_BILLION*2), RealTime(0, 0));
66 QCOMPARE(RealTime(2, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2));
67
68 QCOMPARE(RealTime(-2, ONE_BILLION*2), RealTime(0, 0));
69 QCOMPARE(RealTime(-2, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2));
70
71 QCOMPARE(RealTime(0, 1).sec, 0);
72 QCOMPARE(RealTime(0, 1).nsec, 1);
73 QCOMPARE(RealTime(0, -1).sec, 0);
74 QCOMPARE(RealTime(0, -1).nsec, -1);
75 QCOMPARE(RealTime(1, -1).sec, 0);
76 QCOMPARE(RealTime(1, -1).nsec, ONE_BILLION-1);
77 QCOMPARE(RealTime(-1, 1).sec, 0);
78 QCOMPARE(RealTime(-1, 1).nsec, -ONE_BILLION+1);
79 QCOMPARE(RealTime(-1, -1).sec, -1);
80 QCOMPARE(RealTime(-1, -1).nsec, -1);
81
82 QCOMPARE(RealTime(2, -ONE_BILLION*2).sec, 0);
83 QCOMPARE(RealTime(2, -ONE_BILLION*2).nsec, 0);
84 QCOMPARE(RealTime(2, -ONE_BILLION/2).sec, 1);
85 QCOMPARE(RealTime(2, -ONE_BILLION/2).nsec, ONE_BILLION/2);
86
87 QCOMPARE(RealTime(-2, ONE_BILLION*2).sec, 0);
88 QCOMPARE(RealTime(-2, ONE_BILLION*2).nsec, 0);
89 QCOMPARE(RealTime(-2, ONE_BILLION/2).sec, -1);
90 QCOMPARE(RealTime(-2, ONE_BILLION/2).nsec, -ONE_BILLION/2);
91 }
92
93 void fromSeconds()
94 {
95 QCOMPARE(RealTime::fromSeconds(0), RealTime(0, 0));
96
97 QCOMPARE(RealTime::fromSeconds(0.5).sec, 0);
98 QCOMPARE(RealTime::fromSeconds(0.5).nsec, ONE_BILLION/2);
99 QCOMPARE(RealTime::fromSeconds(0.5).usec(), ONE_MILLION/2);
100 QCOMPARE(RealTime::fromSeconds(0.5).msec(), 500);
101
102 QCOMPARE(RealTime::fromSeconds(0.5), RealTime(0, ONE_BILLION/2));
103 QCOMPARE(RealTime::fromSeconds(1), RealTime(1, 0));
104 QCOMPARE(RealTime::fromSeconds(1.5), RealTime(1, ONE_BILLION/2));
105
106 QCOMPARE(RealTime::fromSeconds(-0.5).sec, 0);
107 QCOMPARE(RealTime::fromSeconds(-0.5).nsec, -ONE_BILLION/2);
108 QCOMPARE(RealTime::fromSeconds(-0.5).usec(), -ONE_MILLION/2);
109 QCOMPARE(RealTime::fromSeconds(-0.5).msec(), -500);
110
111 QCOMPARE(RealTime::fromSeconds(-1.5).sec, -1);
112 QCOMPARE(RealTime::fromSeconds(-1.5).nsec, -ONE_BILLION/2);
113 QCOMPARE(RealTime::fromSeconds(-1.5).usec(), -ONE_MILLION/2);
114 QCOMPARE(RealTime::fromSeconds(-1.5).msec(), -500);
115
116 QCOMPARE(RealTime::fromSeconds(-0.5), RealTime(0, -ONE_BILLION/2));
117 QCOMPARE(RealTime::fromSeconds(-1), RealTime(-1, 0));
118 QCOMPARE(RealTime::fromSeconds(-1.5), RealTime(-1, -ONE_BILLION/2));
119 }
120
121 void fromMilliseconds()
122 {
123 QCOMPARE(RealTime::fromMilliseconds(0), RealTime(0, 0));
124 QCOMPARE(RealTime::fromMilliseconds(500), RealTime(0, ONE_BILLION/2));
125 QCOMPARE(RealTime::fromMilliseconds(1000), RealTime(1, 0));
126 QCOMPARE(RealTime::fromMilliseconds(1500), RealTime(1, ONE_BILLION/2));
127
128 QCOMPARE(RealTime::fromMilliseconds(-0), RealTime(0, 0));
129 QCOMPARE(RealTime::fromMilliseconds(-500), RealTime(0, -ONE_BILLION/2));
130 QCOMPARE(RealTime::fromMilliseconds(-1000), RealTime(-1, 0));
131 QCOMPARE(RealTime::fromMilliseconds(-1500), RealTime(-1, -ONE_BILLION/2));
132 }
133
134 void fromTimeval()
135 {
136 struct timeval tv;
137
138 tv.tv_sec = 0; tv.tv_usec = 0;
139 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, 0));
140 tv.tv_sec = 0; tv.tv_usec = ONE_MILLION/2;
141 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, ONE_BILLION/2));
142 tv.tv_sec = 1; tv.tv_usec = 0;
143 QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, 0));
144 tv.tv_sec = 1; tv.tv_usec = ONE_MILLION/2;
145 QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, ONE_BILLION/2));
146
147 tv.tv_sec = 0; tv.tv_usec = -ONE_MILLION/2;
148 QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, -ONE_BILLION/2));
149 tv.tv_sec = -1; tv.tv_usec = 0;
150 QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, 0));
151 tv.tv_sec = -1; tv.tv_usec = -ONE_MILLION/2;
152 QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, -ONE_BILLION/2));
153 }
154
155 void fromXsdDuration()
156 {
157 QCOMPARE(RealTime::fromXsdDuration("PT0"), RealTime::zeroTime);
158 QCOMPARE(RealTime::fromXsdDuration("PT0S"), RealTime::zeroTime);
159 QCOMPARE(RealTime::fromXsdDuration("PT10S"), RealTime(10, 0));
160 QCOMPARE(RealTime::fromXsdDuration("PT10.5S"), RealTime(10, ONE_BILLION/2));
161 QCOMPARE(RealTime::fromXsdDuration("PT1.5S").sec, 1);
162 QCOMPARE(RealTime::fromXsdDuration("PT1.5S").msec(), 500);
163 QCOMPARE(RealTime::fromXsdDuration("-PT1.5S").sec, -1);
164 QCOMPARE(RealTime::fromXsdDuration("-PT1.5S").msec(), -500);
165 QCOMPARE(RealTime::fromXsdDuration("PT1M30.5S"), RealTime(90, ONE_BILLION/2));
166 QCOMPARE(RealTime::fromXsdDuration("PT1H2M30.5S"), RealTime(3750, ONE_BILLION/2));
167 }
168
169 void toDouble()
170 {
171 QCOMPARE(RealTime(0, 0).toDouble(), 0.0);
172 QCOMPARE(RealTime(0, ONE_BILLION/2).toDouble(), 0.5);
173 QCOMPARE(RealTime(1, 0).toDouble(), 1.0);
174 QCOMPARE(RealTime(1, ONE_BILLION/2).toDouble(), 1.5);
175
176 QCOMPARE(RealTime(0, -ONE_BILLION/2).toDouble(), -0.5);
177 QCOMPARE(RealTime(-1, 0).toDouble(), -1.0);
178 QCOMPARE(RealTime(-1, -ONE_BILLION/2).toDouble(), -1.5);
179 }
180
181 void assign()
182 {
183 RealTime r;
184 r = RealTime(0, 0);
185 QCOMPARE(r, RealTime::zeroTime);
186 r = RealTime(0, ONE_BILLION/2);
187 QCOMPARE(r.sec, 0);
188 QCOMPARE(r.nsec, ONE_BILLION/2);
189 r = RealTime(-1, -ONE_BILLION/2);
190 QCOMPARE(r.sec, -1);
191 QCOMPARE(r.nsec, -ONE_BILLION/2);
192 }
193
194 void plus()
195 {
196 QCOMPARE(RealTime(0, 0) + RealTime(0, 0), RealTime(0, 0));
197
198 QCOMPARE(RealTime(0, 0) + RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2));
199 QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(0, ONE_BILLION/2), RealTime(1, 0));
200 QCOMPARE(RealTime(1, 0) + RealTime(0, ONE_BILLION/2), RealTime(1, ONE_BILLION/2));
201
202 QCOMPARE(RealTime(0, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2));
203 QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(-1, 0));
204 QCOMPARE(RealTime(-1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2));
205
206 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2));
207 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, 0));
208 QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2));
209
210 QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(-1, 0), RealTime(0, -ONE_BILLION/2));
211 QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(1, 0), RealTime(0, ONE_BILLION/2));
212 }
213
214 void minus()
215 {
216 QCOMPARE(RealTime(0, 0) - RealTime(0, 0), RealTime(0, 0));
217
218 QCOMPARE(RealTime(0, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, -ONE_BILLION/2));
219 QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(0, ONE_BILLION/2), RealTime(0, 0));
220 QCOMPARE(RealTime(1, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2));
221
222 QCOMPARE(RealTime(0, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2));
223 QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(0, 0));
224 QCOMPARE(RealTime(-1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2));
225
226 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2));
227 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, 0));
228 QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, ONE_BILLION/2));
229
230 QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(-1, 0), RealTime(1, ONE_BILLION/2));
231 QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(1, 0), RealTime(-1, -ONE_BILLION/2));
232 }
233
234 void negate()
235 {
236 QCOMPARE(-RealTime(0, 0), RealTime(0, 0));
237 QCOMPARE(-RealTime(1, 0), RealTime(-1, 0));
238 QCOMPARE(-RealTime(1, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2));
239 QCOMPARE(-RealTime(-1, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2));
240 }
241
242 void compare()
243 {
244 int sec, nsec;
245 for (sec = -2; sec <= 2; sec += 2) {
246 for (nsec = -1; nsec <= 1; nsec += 1) {
247 QCOMPARE(RealTime(sec, nsec) < RealTime(sec, nsec), false);
248 QCOMPARE(RealTime(sec, nsec) > RealTime(sec, nsec), false);
249 QCOMPARE(RealTime(sec, nsec) == RealTime(sec, nsec), true);
250 QCOMPARE(RealTime(sec, nsec) != RealTime(sec, nsec), false);
251 QCOMPARE(RealTime(sec, nsec) <= RealTime(sec, nsec), true);
252 QCOMPARE(RealTime(sec, nsec) >= RealTime(sec, nsec), true);
253 }
254 }
255 RealTime prev(-3, 0);
256 for (sec = -2; sec <= 2; sec += 2) {
257 for (nsec = -1; nsec <= 1; nsec += 1) {
258
259 RealTime curr(sec, nsec);
260
261 QCOMPARE(prev < curr, true);
262 QCOMPARE(prev > curr, false);
263 QCOMPARE(prev == curr, false);
264 QCOMPARE(prev != curr, true);
265 QCOMPARE(prev <= curr, true);
266 QCOMPARE(prev >= curr, false);
267
268 QCOMPARE(curr < prev, false);
269 QCOMPARE(curr > prev, true);
270 QCOMPARE(curr == prev, false);
271 QCOMPARE(curr != prev, true);
272 QCOMPARE(curr <= prev, false);
273 QCOMPARE(curr >= prev, true);
274
275 prev = curr;
276 }
277 }
278 }
279
280 void frame()
281 {
282 int frames[] = {
283 0, 1, 2047, 2048, 6656,
284 32767, 32768, 44100, 44101,
285 999999999, 2000000000
286 };
287 int n = sizeof(frames)/sizeof(frames[0]);
288
289 int rates[] = {
290 1, 2, 8000, 22050,
291 44100, 44101, 192000, 2000000001
292 };
293 int m = sizeof(rates)/sizeof(rates[0]);
294
295 vector<vector<RealTime>> realTimes = {
296 { { 0, 0 }, { 1, 0 }, { 2047, 0 }, { 2048, 0 },
297 { 6656, 0 }, { 32767, 0 }, { 32768, 0 }, { 44100, 0 },
298 { 44101, 0 }, { 999999999, 0 }, { 2000000000, 0 } },
299 { { 0, 0 }, { 0, 500000000 }, { 1023, 500000000 }, { 1024, 0 },
300 { 3328, 0 }, { 16383, 500000000 }, { 16384, 0 }, { 22050, 0 },
301 { 22050, 500000000 }, { 499999999, 500000000 }, { 1000000000, 0 } },
302 { { 0, 0 }, { 0, 125000 }, { 0, 255875000 }, { 0, 256000000 },
303 { 0, 832000000 }, { 4, 95875000 }, { 4, 96000000 }, { 5, 512500000 },
304 { 5, 512625000 }, { 124999, 999875000 }, { 250000, 0 } },
305 { { 0, 0 }, { 0, 45351 }, { 0, 92834467 }, { 0, 92879819 },
306 { 0, 301859410 }, { 1, 486031746 }, { 1, 486077098 }, { 2, 0 },
307 { 2, 45351 }, { 45351, 473877551 }, { 90702, 947845805 } },
308 { { 0, 0 }, { 0, 22676 }, { 0, 46417234 }, { 0, 46439909 },
309 { 0, 150929705 }, { 0, 743015873 }, { 0, 743038549 }, { 1, 0 },
310 { 1, 22676 }, { 22675, 736938776 }, { 45351, 473922902 } },
311 { { 0, 0 }, { 0, 22675 }, { 0, 46416181 }, { 0, 46438856 },
312 { 0, 150926283 }, { 0, 742999025 }, { 0, 743021700 }, { 0, 999977325 },
313 { 1, 0 }, { 22675, 222761389 }, { 45350, 445568128 } },
314 { { 0, 0 }, { 0, 5208 }, { 0, 10661458 }, { 0, 10666667 },
315 { 0, 34666667 }, { 0, 170661458 }, { 0, 170666667 }, { 0, 229687500 },
316 { 0, 229692708 }, { 5208, 333328125 }, { 10416, 666666667 } },
317 { { 0, 0 }, { 0, 0 }, { 0, 1023 }, { 0, 1024 },
318 { 0, 3328 }, { 0, 16383 }, { 0, 16384 }, { 0, 22050 },
319 { 0, 22050 }, { 0, 499999999 }, { 1, 0 } }
320 };
321
322 for (int i = 0; i < n; ++i) {
323 frame_type frame = frames[i];
324 for (int j = 0; j < m; ++j) {
325 int rate = rates[j];
326
327 cerr << "frame = " << frame << ", rate = " << rate << endl;
328
329 RealTime rt = RealTime::frame2RealTime(frame, rate);
330 QCOMPARE(rt.sec, realTimes[j][i].sec);
331 QCOMPARE(rt.nsec, realTimes[j][i].nsec);
332
333 cerr << "rt = " << rt << endl;
334 cerr << "rate = " << rate << endl;
335
336 frame_type conv = RealTime::realTime2Frame(rt, rate);
337 cerr << "conv = " << conv << endl;
338
339 rt = RealTime::frame2RealTime(-frame, rate);
340 frame_type negconv = RealTime::realTime2Frame(rt, rate);
341 cerr << "negconv = " << negconv << endl;
342
343 if (rate > ONE_BILLION) {
344 // We no longer have enough precision in RealTime
345 // for this absurd sample rate, so a round trip
346 // conversion may round
347 QVERIFY(abs(frame - conv) < 2);
348 QVERIFY(abs(-frame - negconv) < 2);
349 } else {
350 QCOMPARE(conv, frame);
351 QCOMPARE(negconv, -frame);
352 }
353 }
354 }
355 }
356
357 // Our own RealTime has toMSText, toFrameText, toSecText
358
359 void toText()
360 {
361 // we want to use QStrings, because then the Qt test library
362 // will print out any conflicts. The compareTexts function
363 // does this for us
364
365 int halfSec = ONE_BILLION/2; // nsec
366
367 RealTime rt = RealTime(0, 0);
368 compareTexts(rt.toMSText(false, false), "0");
369 compareTexts(rt.toMSText(true, false), "0.000");
370 compareTexts(rt.toMSText(false, true), "0");
371 compareTexts(rt.toMSText(true, true), "0.000");
372 compareTexts(rt.toFrameText(24, false), "0:00");
373 compareTexts(rt.toFrameText(24, true), "0:00");
374 compareTexts(rt.toSecText(), "0s");
375
376 rt = RealTime(1, halfSec);
377 compareTexts(rt.toMSText(false, false), "1.5");
378 compareTexts(rt.toMSText(true, false), "1.500");
379 compareTexts(rt.toMSText(false, true), "1.5");
380 compareTexts(rt.toMSText(true, true), "1.500");
381 compareTexts(rt.toFrameText(24, false), "1:12");
382 compareTexts(rt.toFrameText(24, true), "1:12");
383 compareTexts(rt.toFrameText(25, false), "1:12");
384 compareTexts(rt.toFrameText(25, true), "1:12");
385 compareTexts(rt.toSecText(), "1s");
386
387 rt = RealTime::fromSeconds(-1.5);
388 compareTexts(rt.toMSText(false, false), "-1.5");
389 compareTexts(rt.toMSText(true, false), "-1.500");
390 compareTexts(rt.toMSText(false, true), "-1.5");
391 compareTexts(rt.toMSText(true, true), "-1.500");
392 compareTexts(rt.toFrameText(24, false), "-1:12");
393 compareTexts(rt.toFrameText(24, true), "-1:12");
394 compareTexts(rt.toSecText(), "-1s");
395
396 rt = RealTime(1, 1000);
397 compareTexts(rt.toMSText(false, false), "1");
398 compareTexts(rt.toFrameText(24, false), "1:00");
399 compareTexts(rt.toFrameText(ONE_MILLION, false), "1:000001");
400 compareTexts(rt.toSecText(), "1s");
401
402 rt = RealTime(1, 100000);
403 compareTexts(rt.toFrameText(ONE_MILLION, false), "1:000100");
404 compareTexts(rt.toSecText(), "1s");
405
406 rt = RealTime::fromSeconds(60);
407 compareTexts(rt.toMSText(false, false), "60");
408 compareTexts(rt.toMSText(true, false), "60.000");
409 compareTexts(rt.toMSText(false, true), "1:00");
410 compareTexts(rt.toMSText(true, true), "1:00.000");
411 compareTexts(rt.toFrameText(24, false), "60:00");
412 compareTexts(rt.toFrameText(24, true), "1:00:00");
413 compareTexts(rt.toSecText(), "1:00");
414
415 rt = RealTime::fromSeconds(61.05);
416 compareTexts(rt.toMSText(false, false), "61.05");
417 compareTexts(rt.toMSText(true, false), "61.050");
418 compareTexts(rt.toMSText(false, true), "1:01.05");
419 compareTexts(rt.toMSText(true, true), "1:01.050");
420 compareTexts(rt.toFrameText(24, false), "61:01");
421 compareTexts(rt.toFrameText(24, true), "1:01:01");
422 compareTexts(rt.toSecText(), "1:01");
423
424 rt = RealTime::fromSeconds(601.05);
425 compareTexts(rt.toMSText(false, false), "601.05");
426 compareTexts(rt.toMSText(true, false), "601.050");
427 compareTexts(rt.toMSText(false, true), "10:01.05");
428 compareTexts(rt.toMSText(true, true), "10:01.050");
429 compareTexts(rt.toFrameText(24, false), "601:01");
430 compareTexts(rt.toFrameText(24, true), "10:01:01");
431 compareTexts(rt.toSecText(), "10:01");
432
433 rt = RealTime::fromSeconds(3600);
434 compareTexts(rt.toMSText(false, false), "3600");
435 compareTexts(rt.toMSText(true, false), "3600.000");
436 compareTexts(rt.toMSText(false, true), "1:00:00");
437 compareTexts(rt.toMSText(true, true), "1:00:00.000");
438 compareTexts(rt.toFrameText(24, false), "3600:00");
439 compareTexts(rt.toFrameText(24, true), "1:00:00:00");
440 compareTexts(rt.toSecText(), "1:00:00");
441
442 // For practical reasons our time display always rounds down
443 rt = RealTime(3599, ONE_BILLION-1);
444 compareTexts(rt.toMSText(false, false), "3599.999");
445 compareTexts(rt.toMSText(true, false), "3599.999");
446 compareTexts(rt.toMSText(false, true), "59:59.999");
447 compareTexts(rt.toMSText(true, true), "59:59.999");
448 compareTexts(rt.toFrameText(24, false), "3599:23");
449 compareTexts(rt.toFrameText(24, true), "59:59:23");
450 compareTexts(rt.toSecText(), "59:59");
451
452 rt = RealTime::fromSeconds(3600 * 4 + 60 * 5 + 3 + 0.01);
453 compareTexts(rt.toMSText(false, false), "14703.01");
454 compareTexts(rt.toMSText(true, false), "14703.010");
455 compareTexts(rt.toMSText(false, true), "4:05:03.01");
456 compareTexts(rt.toMSText(true, true), "4:05:03.010");
457 compareTexts(rt.toFrameText(24, false), "14703:00");
458 compareTexts(rt.toFrameText(24, true), "4:05:03:00");
459 compareTexts(rt.toSecText(), "4:05:03");
460
461 rt = RealTime::fromSeconds(-(3600 * 4 + 60 * 5 + 3 + 0.01));
462 compareTexts(rt.toMSText(false, false), "-14703.01");
463 compareTexts(rt.toMSText(true, false), "-14703.010");
464 compareTexts(rt.toMSText(false, true), "-4:05:03.01");
465 compareTexts(rt.toMSText(true, true), "-4:05:03.010");
466 compareTexts(rt.toFrameText(24, false), "-14703:00");
467 compareTexts(rt.toFrameText(24, true), "-4:05:03:00");
468 compareTexts(rt.toSecText(), "-4:05:03");
469 }
470 };
471
472 #endif
473