Mercurial > hg > svcore
diff base/test/TestOurRealTime.h @ 1344:980afe3f1a76 3.0-integration
Untabify, comment test that doesn't apply on Windows
author | Chris Cannam |
---|---|
date | Fri, 06 Jan 2017 11:21:09 +0000 |
parents | b7b84ae5f0a7 |
children | 622d193a00dc |
line wrap: on
line diff
--- a/base/test/TestOurRealTime.h Fri Jan 06 09:50:13 2017 +0000 +++ b/base/test/TestOurRealTime.h Fri Jan 06 11:21:09 2017 +0000 @@ -42,242 +42,242 @@ void zero() { - QCOMPARE(RealTime(0, 0), RealTime::zeroTime); - QCOMPARE(RealTime(0, 0).sec, 0); - QCOMPARE(RealTime(0, 0).nsec, 0); - QCOMPARE(RealTime(0, 0).msec(), 0); - QCOMPARE(RealTime(0, 0).usec(), 0); + QCOMPARE(RealTime(0, 0), RealTime::zeroTime); + QCOMPARE(RealTime(0, 0).sec, 0); + QCOMPARE(RealTime(0, 0).nsec, 0); + QCOMPARE(RealTime(0, 0).msec(), 0); + QCOMPARE(RealTime(0, 0).usec(), 0); } void ctor() { - QCOMPARE(RealTime(0, 0), RealTime(0, 0)); + QCOMPARE(RealTime(0, 0), RealTime(0, 0)); - // wraparounds - QCOMPARE(RealTime(0, ONE_BILLION/2), RealTime(1, -ONE_BILLION/2)); - QCOMPARE(RealTime(0, -ONE_BILLION/2), RealTime(-1, ONE_BILLION/2)); + // wraparounds + QCOMPARE(RealTime(0, ONE_BILLION/2), RealTime(1, -ONE_BILLION/2)); + QCOMPARE(RealTime(0, -ONE_BILLION/2), RealTime(-1, ONE_BILLION/2)); - QCOMPARE(RealTime(1, ONE_BILLION), RealTime(2, 0)); - QCOMPARE(RealTime(1, -ONE_BILLION), RealTime(0, 0)); - QCOMPARE(RealTime(-1, ONE_BILLION), RealTime(0, 0)); - QCOMPARE(RealTime(-1, -ONE_BILLION), RealTime(-2, 0)); + QCOMPARE(RealTime(1, ONE_BILLION), RealTime(2, 0)); + QCOMPARE(RealTime(1, -ONE_BILLION), RealTime(0, 0)); + QCOMPARE(RealTime(-1, ONE_BILLION), RealTime(0, 0)); + QCOMPARE(RealTime(-1, -ONE_BILLION), RealTime(-2, 0)); QCOMPARE(RealTime(1, -ONE_BILLION-ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); QCOMPARE(RealTime(-1, ONE_BILLION+ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); - QCOMPARE(RealTime(2, -ONE_BILLION*2), RealTime(0, 0)); - QCOMPARE(RealTime(2, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); + QCOMPARE(RealTime(2, -ONE_BILLION*2), RealTime(0, 0)); + QCOMPARE(RealTime(2, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); - QCOMPARE(RealTime(-2, ONE_BILLION*2), RealTime(0, 0)); - QCOMPARE(RealTime(-2, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); - - QCOMPARE(RealTime(0, 1).sec, 0); - QCOMPARE(RealTime(0, 1).nsec, 1); - QCOMPARE(RealTime(0, -1).sec, 0); - QCOMPARE(RealTime(0, -1).nsec, -1); - QCOMPARE(RealTime(1, -1).sec, 0); - QCOMPARE(RealTime(1, -1).nsec, ONE_BILLION-1); - QCOMPARE(RealTime(-1, 1).sec, 0); - QCOMPARE(RealTime(-1, 1).nsec, -ONE_BILLION+1); - QCOMPARE(RealTime(-1, -1).sec, -1); - QCOMPARE(RealTime(-1, -1).nsec, -1); - - QCOMPARE(RealTime(2, -ONE_BILLION*2).sec, 0); - QCOMPARE(RealTime(2, -ONE_BILLION*2).nsec, 0); - QCOMPARE(RealTime(2, -ONE_BILLION/2).sec, 1); - QCOMPARE(RealTime(2, -ONE_BILLION/2).nsec, ONE_BILLION/2); + QCOMPARE(RealTime(-2, ONE_BILLION*2), RealTime(0, 0)); + QCOMPARE(RealTime(-2, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); + + QCOMPARE(RealTime(0, 1).sec, 0); + QCOMPARE(RealTime(0, 1).nsec, 1); + QCOMPARE(RealTime(0, -1).sec, 0); + QCOMPARE(RealTime(0, -1).nsec, -1); + QCOMPARE(RealTime(1, -1).sec, 0); + QCOMPARE(RealTime(1, -1).nsec, ONE_BILLION-1); + QCOMPARE(RealTime(-1, 1).sec, 0); + QCOMPARE(RealTime(-1, 1).nsec, -ONE_BILLION+1); + QCOMPARE(RealTime(-1, -1).sec, -1); + QCOMPARE(RealTime(-1, -1).nsec, -1); + + QCOMPARE(RealTime(2, -ONE_BILLION*2).sec, 0); + QCOMPARE(RealTime(2, -ONE_BILLION*2).nsec, 0); + QCOMPARE(RealTime(2, -ONE_BILLION/2).sec, 1); + QCOMPARE(RealTime(2, -ONE_BILLION/2).nsec, ONE_BILLION/2); - QCOMPARE(RealTime(-2, ONE_BILLION*2).sec, 0); - QCOMPARE(RealTime(-2, ONE_BILLION*2).nsec, 0); - QCOMPARE(RealTime(-2, ONE_BILLION/2).sec, -1); - QCOMPARE(RealTime(-2, ONE_BILLION/2).nsec, -ONE_BILLION/2); + QCOMPARE(RealTime(-2, ONE_BILLION*2).sec, 0); + QCOMPARE(RealTime(-2, ONE_BILLION*2).nsec, 0); + QCOMPARE(RealTime(-2, ONE_BILLION/2).sec, -1); + QCOMPARE(RealTime(-2, ONE_BILLION/2).nsec, -ONE_BILLION/2); } void fromSeconds() { - QCOMPARE(RealTime::fromSeconds(0), RealTime(0, 0)); + QCOMPARE(RealTime::fromSeconds(0), RealTime(0, 0)); - QCOMPARE(RealTime::fromSeconds(0.5).sec, 0); - QCOMPARE(RealTime::fromSeconds(0.5).nsec, ONE_BILLION/2); - QCOMPARE(RealTime::fromSeconds(0.5).usec(), ONE_MILLION/2); - QCOMPARE(RealTime::fromSeconds(0.5).msec(), 500); - - QCOMPARE(RealTime::fromSeconds(0.5), RealTime(0, ONE_BILLION/2)); - QCOMPARE(RealTime::fromSeconds(1), RealTime(1, 0)); - QCOMPARE(RealTime::fromSeconds(1.5), RealTime(1, ONE_BILLION/2)); + QCOMPARE(RealTime::fromSeconds(0.5).sec, 0); + QCOMPARE(RealTime::fromSeconds(0.5).nsec, ONE_BILLION/2); + QCOMPARE(RealTime::fromSeconds(0.5).usec(), ONE_MILLION/2); + QCOMPARE(RealTime::fromSeconds(0.5).msec(), 500); + + QCOMPARE(RealTime::fromSeconds(0.5), RealTime(0, ONE_BILLION/2)); + QCOMPARE(RealTime::fromSeconds(1), RealTime(1, 0)); + QCOMPARE(RealTime::fromSeconds(1.5), RealTime(1, ONE_BILLION/2)); - QCOMPARE(RealTime::fromSeconds(-0.5).sec, 0); - QCOMPARE(RealTime::fromSeconds(-0.5).nsec, -ONE_BILLION/2); - QCOMPARE(RealTime::fromSeconds(-0.5).usec(), -ONE_MILLION/2); - QCOMPARE(RealTime::fromSeconds(-0.5).msec(), -500); - - QCOMPARE(RealTime::fromSeconds(-1.5).sec, -1); - QCOMPARE(RealTime::fromSeconds(-1.5).nsec, -ONE_BILLION/2); - QCOMPARE(RealTime::fromSeconds(-1.5).usec(), -ONE_MILLION/2); - QCOMPARE(RealTime::fromSeconds(-1.5).msec(), -500); - - QCOMPARE(RealTime::fromSeconds(-0.5), RealTime(0, -ONE_BILLION/2)); - QCOMPARE(RealTime::fromSeconds(-1), RealTime(-1, 0)); - QCOMPARE(RealTime::fromSeconds(-1.5), RealTime(-1, -ONE_BILLION/2)); + QCOMPARE(RealTime::fromSeconds(-0.5).sec, 0); + QCOMPARE(RealTime::fromSeconds(-0.5).nsec, -ONE_BILLION/2); + QCOMPARE(RealTime::fromSeconds(-0.5).usec(), -ONE_MILLION/2); + QCOMPARE(RealTime::fromSeconds(-0.5).msec(), -500); + + QCOMPARE(RealTime::fromSeconds(-1.5).sec, -1); + QCOMPARE(RealTime::fromSeconds(-1.5).nsec, -ONE_BILLION/2); + QCOMPARE(RealTime::fromSeconds(-1.5).usec(), -ONE_MILLION/2); + QCOMPARE(RealTime::fromSeconds(-1.5).msec(), -500); + + QCOMPARE(RealTime::fromSeconds(-0.5), RealTime(0, -ONE_BILLION/2)); + QCOMPARE(RealTime::fromSeconds(-1), RealTime(-1, 0)); + QCOMPARE(RealTime::fromSeconds(-1.5), RealTime(-1, -ONE_BILLION/2)); } void fromMilliseconds() { - QCOMPARE(RealTime::fromMilliseconds(0), RealTime(0, 0)); - QCOMPARE(RealTime::fromMilliseconds(500), RealTime(0, ONE_BILLION/2)); - QCOMPARE(RealTime::fromMilliseconds(1000), RealTime(1, 0)); - QCOMPARE(RealTime::fromMilliseconds(1500), RealTime(1, ONE_BILLION/2)); + QCOMPARE(RealTime::fromMilliseconds(0), RealTime(0, 0)); + QCOMPARE(RealTime::fromMilliseconds(500), RealTime(0, ONE_BILLION/2)); + QCOMPARE(RealTime::fromMilliseconds(1000), RealTime(1, 0)); + QCOMPARE(RealTime::fromMilliseconds(1500), RealTime(1, ONE_BILLION/2)); - QCOMPARE(RealTime::fromMilliseconds(-0), RealTime(0, 0)); - QCOMPARE(RealTime::fromMilliseconds(-500), RealTime(0, -ONE_BILLION/2)); - QCOMPARE(RealTime::fromMilliseconds(-1000), RealTime(-1, 0)); - QCOMPARE(RealTime::fromMilliseconds(-1500), RealTime(-1, -ONE_BILLION/2)); + QCOMPARE(RealTime::fromMilliseconds(-0), RealTime(0, 0)); + QCOMPARE(RealTime::fromMilliseconds(-500), RealTime(0, -ONE_BILLION/2)); + QCOMPARE(RealTime::fromMilliseconds(-1000), RealTime(-1, 0)); + QCOMPARE(RealTime::fromMilliseconds(-1500), RealTime(-1, -ONE_BILLION/2)); } void fromTimeval() { - struct timeval tv; + struct timeval tv; - tv.tv_sec = 0; tv.tv_usec = 0; - QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, 0)); - tv.tv_sec = 0; tv.tv_usec = ONE_MILLION/2; - QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, ONE_BILLION/2)); - tv.tv_sec = 1; tv.tv_usec = 0; - QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, 0)); - tv.tv_sec = 1; tv.tv_usec = ONE_MILLION/2; - QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, ONE_BILLION/2)); + tv.tv_sec = 0; tv.tv_usec = 0; + QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, 0)); + tv.tv_sec = 0; tv.tv_usec = ONE_MILLION/2; + QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, ONE_BILLION/2)); + tv.tv_sec = 1; tv.tv_usec = 0; + QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, 0)); + tv.tv_sec = 1; tv.tv_usec = ONE_MILLION/2; + QCOMPARE(RealTime::fromTimeval(tv), RealTime(1, ONE_BILLION/2)); - tv.tv_sec = 0; tv.tv_usec = -ONE_MILLION/2; - QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, -ONE_BILLION/2)); - tv.tv_sec = -1; tv.tv_usec = 0; - QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, 0)); - tv.tv_sec = -1; tv.tv_usec = -ONE_MILLION/2; - QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, -ONE_BILLION/2)); + tv.tv_sec = 0; tv.tv_usec = -ONE_MILLION/2; + QCOMPARE(RealTime::fromTimeval(tv), RealTime(0, -ONE_BILLION/2)); + tv.tv_sec = -1; tv.tv_usec = 0; + QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, 0)); + tv.tv_sec = -1; tv.tv_usec = -ONE_MILLION/2; + QCOMPARE(RealTime::fromTimeval(tv), RealTime(-1, -ONE_BILLION/2)); } void fromXsdDuration() { - QCOMPARE(RealTime::fromXsdDuration("PT0"), RealTime::zeroTime); - QCOMPARE(RealTime::fromXsdDuration("PT0S"), RealTime::zeroTime); - QCOMPARE(RealTime::fromXsdDuration("PT10S"), RealTime(10, 0)); - QCOMPARE(RealTime::fromXsdDuration("PT10.5S"), RealTime(10, ONE_BILLION/2)); - QCOMPARE(RealTime::fromXsdDuration("PT1.5S").sec, 1); - QCOMPARE(RealTime::fromXsdDuration("PT1.5S").msec(), 500); - QCOMPARE(RealTime::fromXsdDuration("-PT1.5S").sec, -1); - QCOMPARE(RealTime::fromXsdDuration("-PT1.5S").msec(), -500); - QCOMPARE(RealTime::fromXsdDuration("PT1M30.5S"), RealTime(90, ONE_BILLION/2)); - QCOMPARE(RealTime::fromXsdDuration("PT1H2M30.5S"), RealTime(3750, ONE_BILLION/2)); + QCOMPARE(RealTime::fromXsdDuration("PT0"), RealTime::zeroTime); + QCOMPARE(RealTime::fromXsdDuration("PT0S"), RealTime::zeroTime); + QCOMPARE(RealTime::fromXsdDuration("PT10S"), RealTime(10, 0)); + QCOMPARE(RealTime::fromXsdDuration("PT10.5S"), RealTime(10, ONE_BILLION/2)); + QCOMPARE(RealTime::fromXsdDuration("PT1.5S").sec, 1); + QCOMPARE(RealTime::fromXsdDuration("PT1.5S").msec(), 500); + QCOMPARE(RealTime::fromXsdDuration("-PT1.5S").sec, -1); + QCOMPARE(RealTime::fromXsdDuration("-PT1.5S").msec(), -500); + QCOMPARE(RealTime::fromXsdDuration("PT1M30.5S"), RealTime(90, ONE_BILLION/2)); + QCOMPARE(RealTime::fromXsdDuration("PT1H2M30.5S"), RealTime(3750, ONE_BILLION/2)); } void toDouble() { - QCOMPARE(RealTime(0, 0).toDouble(), 0.0); - QCOMPARE(RealTime(0, ONE_BILLION/2).toDouble(), 0.5); - QCOMPARE(RealTime(1, 0).toDouble(), 1.0); - QCOMPARE(RealTime(1, ONE_BILLION/2).toDouble(), 1.5); + QCOMPARE(RealTime(0, 0).toDouble(), 0.0); + QCOMPARE(RealTime(0, ONE_BILLION/2).toDouble(), 0.5); + QCOMPARE(RealTime(1, 0).toDouble(), 1.0); + QCOMPARE(RealTime(1, ONE_BILLION/2).toDouble(), 1.5); - QCOMPARE(RealTime(0, -ONE_BILLION/2).toDouble(), -0.5); - QCOMPARE(RealTime(-1, 0).toDouble(), -1.0); - QCOMPARE(RealTime(-1, -ONE_BILLION/2).toDouble(), -1.5); + QCOMPARE(RealTime(0, -ONE_BILLION/2).toDouble(), -0.5); + QCOMPARE(RealTime(-1, 0).toDouble(), -1.0); + QCOMPARE(RealTime(-1, -ONE_BILLION/2).toDouble(), -1.5); } void assign() { - RealTime r; - r = RealTime(0, 0); - QCOMPARE(r, RealTime::zeroTime); - r = RealTime(0, ONE_BILLION/2); + RealTime r; + r = RealTime(0, 0); + QCOMPARE(r, RealTime::zeroTime); + r = RealTime(0, ONE_BILLION/2); QCOMPARE(r.sec, 0); QCOMPARE(r.nsec, ONE_BILLION/2); - r = RealTime(-1, -ONE_BILLION/2); + r = RealTime(-1, -ONE_BILLION/2); QCOMPARE(r.sec, -1); QCOMPARE(r.nsec, -ONE_BILLION/2); } void plus() { - QCOMPARE(RealTime(0, 0) + RealTime(0, 0), RealTime(0, 0)); + QCOMPARE(RealTime(0, 0) + RealTime(0, 0), RealTime(0, 0)); - QCOMPARE(RealTime(0, 0) + RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); - QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(0, ONE_BILLION/2), RealTime(1, 0)); - QCOMPARE(RealTime(1, 0) + RealTime(0, ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); + QCOMPARE(RealTime(0, 0) + RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); + QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(0, ONE_BILLION/2), RealTime(1, 0)); + QCOMPARE(RealTime(1, 0) + RealTime(0, ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); - QCOMPARE(RealTime(0, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); - QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(-1, 0)); - QCOMPARE(RealTime(-1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); + QCOMPARE(RealTime(0, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); + QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(-1, 0)); + QCOMPARE(RealTime(-1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); - QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); - QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, 0)); - QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); + QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); + QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, 0)); + QCOMPARE(RealTime(1, 0) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2) + RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); - QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(-1, 0), RealTime(0, -ONE_BILLION/2)); - QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(1, 0), RealTime(0, ONE_BILLION/2)); + QCOMPARE(RealTime(0, ONE_BILLION/2) + RealTime(-1, 0), RealTime(0, -ONE_BILLION/2)); + QCOMPARE(RealTime(0, -ONE_BILLION/2) + RealTime(1, 0), RealTime(0, ONE_BILLION/2)); } void minus() { - QCOMPARE(RealTime(0, 0) - RealTime(0, 0), RealTime(0, 0)); + QCOMPARE(RealTime(0, 0) - RealTime(0, 0), RealTime(0, 0)); - QCOMPARE(RealTime(0, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); - QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(0, ONE_BILLION/2), RealTime(0, 0)); - QCOMPARE(RealTime(1, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); + QCOMPARE(RealTime(0, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); + QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(0, ONE_BILLION/2), RealTime(0, 0)); + QCOMPARE(RealTime(1, 0) - RealTime(0, ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); - QCOMPARE(RealTime(0, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); - QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(0, 0)); - QCOMPARE(RealTime(-1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); + QCOMPARE(RealTime(0, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, ONE_BILLION/2)); + QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(0, 0)); + QCOMPARE(RealTime(-1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(0, -ONE_BILLION/2)); - QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); - QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, 0)); - QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, ONE_BILLION/2)); + QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); + QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, 0)); + QCOMPARE(RealTime(1, 0) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2) - RealTime(0, -ONE_BILLION/2), RealTime(2, ONE_BILLION/2)); - QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(-1, 0), RealTime(1, ONE_BILLION/2)); - QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(1, 0), RealTime(-1, -ONE_BILLION/2)); + QCOMPARE(RealTime(0, ONE_BILLION/2) - RealTime(-1, 0), RealTime(1, ONE_BILLION/2)); + QCOMPARE(RealTime(0, -ONE_BILLION/2) - RealTime(1, 0), RealTime(-1, -ONE_BILLION/2)); } void negate() { - QCOMPARE(-RealTime(0, 0), RealTime(0, 0)); - QCOMPARE(-RealTime(1, 0), RealTime(-1, 0)); - QCOMPARE(-RealTime(1, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); - QCOMPARE(-RealTime(-1, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); + QCOMPARE(-RealTime(0, 0), RealTime(0, 0)); + QCOMPARE(-RealTime(1, 0), RealTime(-1, 0)); + QCOMPARE(-RealTime(1, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); + QCOMPARE(-RealTime(-1, -ONE_BILLION/2), RealTime(1, ONE_BILLION/2)); } void compare() { - int sec, nsec; - for (sec = -2; sec <= 2; sec += 2) { - for (nsec = -1; nsec <= 1; nsec += 1) { - QCOMPARE(RealTime(sec, nsec) < RealTime(sec, nsec), false); - QCOMPARE(RealTime(sec, nsec) > RealTime(sec, nsec), false); - QCOMPARE(RealTime(sec, nsec) == RealTime(sec, nsec), true); - QCOMPARE(RealTime(sec, nsec) != RealTime(sec, nsec), false); - QCOMPARE(RealTime(sec, nsec) <= RealTime(sec, nsec), true); - QCOMPARE(RealTime(sec, nsec) >= RealTime(sec, nsec), true); - } - } - RealTime prev(-3, 0); - for (sec = -2; sec <= 2; sec += 2) { - for (nsec = -1; nsec <= 1; nsec += 1) { + int sec, nsec; + for (sec = -2; sec <= 2; sec += 2) { + for (nsec = -1; nsec <= 1; nsec += 1) { + QCOMPARE(RealTime(sec, nsec) < RealTime(sec, nsec), false); + QCOMPARE(RealTime(sec, nsec) > RealTime(sec, nsec), false); + QCOMPARE(RealTime(sec, nsec) == RealTime(sec, nsec), true); + QCOMPARE(RealTime(sec, nsec) != RealTime(sec, nsec), false); + QCOMPARE(RealTime(sec, nsec) <= RealTime(sec, nsec), true); + QCOMPARE(RealTime(sec, nsec) >= RealTime(sec, nsec), true); + } + } + RealTime prev(-3, 0); + for (sec = -2; sec <= 2; sec += 2) { + for (nsec = -1; nsec <= 1; nsec += 1) { - RealTime curr(sec, nsec); + RealTime curr(sec, nsec); - QCOMPARE(prev < curr, true); - QCOMPARE(prev > curr, false); - QCOMPARE(prev == curr, false); - QCOMPARE(prev != curr, true); - QCOMPARE(prev <= curr, true); - QCOMPARE(prev >= curr, false); + QCOMPARE(prev < curr, true); + QCOMPARE(prev > curr, false); + QCOMPARE(prev == curr, false); + QCOMPARE(prev != curr, true); + QCOMPARE(prev <= curr, true); + QCOMPARE(prev >= curr, false); - QCOMPARE(curr < prev, false); - QCOMPARE(curr > prev, true); - QCOMPARE(curr == prev, false); - QCOMPARE(curr != prev, true); - QCOMPARE(curr <= prev, false); - QCOMPARE(curr >= prev, true); + QCOMPARE(curr < prev, false); + QCOMPARE(curr > prev, true); + QCOMPARE(curr == prev, false); + QCOMPARE(curr != prev, true); + QCOMPARE(curr <= prev, false); + QCOMPARE(curr >= prev, true); - prev = curr; - } - } + prev = curr; + } + } } void frame()