time: For tests, subtract in the right order

This was a bug in the test rather than a bug in the code the test was testing.

Use the ternary operator to replace labs.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
This commit is contained in:
Adam C. Emerson 2016-03-11 18:33:59 -05:00 committed by Yehuda Sadeh
parent 1d4c6079e3
commit 99ee598c9e

View File

@ -122,7 +122,9 @@ static void system_clock_conversions() {
ASSERT_EQ(Clock::to_double(brt), bd);
// Fudge factor
ASSERT_LT(abs((Clock::from_double(bd) - brt).count()), 30);
ASSERT_LT((Clock::from_double(bd) > brt ?
Clock::from_double(bd) - brt :
brt - Clock::from_double(bd)).count(), 30U);
}
TEST(RealClock, Sanity) {