1 /* $NetBSD: lfptest.h,v 1.1.1.1 2013/12/27 23:31:38 christos Exp $ */ 2 3 #ifndef NTP_TESTS_LFPTEST_H 4 #define NTP_TESTS_LFPTEST_H 5 6 #include "libntptest.h" 7 8 extern "C" { 9 #include "ntp_fp.h" 10 }; 11 12 class lfptest : public libntptest { 13 protected: 14 ::testing::AssertionResult IsEqual(const l_fp &expected, const l_fp &actual) { 15 if (L_ISEQU(&expected, &actual)) { 16 return ::testing::AssertionSuccess(); 17 } else { 18 return ::testing::AssertionFailure() 19 << " expected: " << lfptoa(&expected, FRACTION_PREC) 20 << " (" << expected.l_ui << "." << expected.l_uf << ")" 21 << " but was: " << lfptoa(&actual, FRACTION_PREC) 22 << " (" << actual.l_ui << "." << actual.l_uf << ")"; 23 } 24 } 25 26 static const int32 HALF = -2147483647L - 1L; 27 static const int32 HALF_PROMILLE_UP = 2147484; // slightly more than 0.0005 28 static const int32 HALF_PROMILLE_DOWN = 2147483; // slightly less than 0.0005 29 static const int32 QUARTER = 1073741824L; 30 static const int32 QUARTER_PROMILLE_APPRX = 1073742L; 31 }; 32 33 #endif /* NTP_TESTS_LFPTEST_H */ 34