]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
time: For tests, subtract in the right order
authorAdam C. Emerson <aemerson@redhat.com>
Fri, 11 Mar 2016 23:33:59 +0000 (18:33 -0500)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 15 Mar 2016 04:44:41 +0000 (21:44 -0700)
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>
src/test/common/test_time.cc

index 2e6ad4bbcbd2bdc4c9d8bebcd6d3834ce51bb61e..a54fe90b83a3af596581e60b624d2c838f793a8d 100644 (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) {