comparison base/test/TestOurRealTime.h @ 1427:622d193a00dc

Rework canonicalisation so as to avoid theoretical possibility of integer overflow
author Chris Cannam
date Mon, 11 Dec 2017 09:28:40 +0000
parents 980afe3f1a76
children 71207822a7e0
comparison
equal deleted inserted replaced
1426:9ae40c7aecdf 1427:622d193a00dc
68 QCOMPARE(RealTime(2, -ONE_BILLION*2), RealTime(0, 0)); 68 QCOMPARE(RealTime(2, -ONE_BILLION*2), RealTime(0, 0));
69 QCOMPARE(RealTime(2, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); 69 QCOMPARE(RealTime(2, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2));
70 70
71 QCOMPARE(RealTime(-2, ONE_BILLION*2), RealTime(0, 0)); 71 QCOMPARE(RealTime(-2, ONE_BILLION*2), RealTime(0, 0));
72 QCOMPARE(RealTime(-2, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); 72 QCOMPARE(RealTime(-2, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2));
73
74 QCOMPARE(RealTime(1, -ONE_BILLION/2).sec, 0);
75 QCOMPARE(RealTime(1, -ONE_BILLION/2).nsec, ONE_BILLION/2);
76 QCOMPARE(RealTime(-1, ONE_BILLION/2).sec, 0);
77 QCOMPARE(RealTime(-1, ONE_BILLION/2).nsec, -ONE_BILLION/2);
73 78
74 QCOMPARE(RealTime(0, 1).sec, 0); 79 QCOMPARE(RealTime(0, 1).sec, 0);
75 QCOMPARE(RealTime(0, 1).nsec, 1); 80 QCOMPARE(RealTime(0, 1).nsec, 1);
76 QCOMPARE(RealTime(0, -1).sec, 0); 81 QCOMPARE(RealTime(0, -1).sec, 0);
77 QCOMPARE(RealTime(0, -1).nsec, -1); 82 QCOMPARE(RealTime(0, -1).nsec, -1);