From: Adam C. Emerson Date: Fri, 11 Mar 2016 23:33:59 +0000 (-0500) Subject: time: For tests, subtract in the right order X-Git-Tag: v10.1.0~73^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=99ee598c9e244a4123055d221bedb1d577b09039;p=ceph.git 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 --- diff --git a/src/test/common/test_time.cc b/src/test/common/test_time.cc index 2e6ad4bbcbd2..a54fe90b83a3 100644 --- a/src/test/common/test_time.cc +++ b/src/test/common/test_time.cc @@ -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) {