[Git][NTPsec/ntpsec][master] EXPECT_DOUBLE_EQ should compare using a double, not a float.

Amar Takhar gitlab at mg.gitlab.com
Wed Dec 9 19:39:00 UTC 2015


Amar Takhar pushed to branch master at NTPsec / ntpsec


Commits:
499c3791 by Matthew Selsky at 2015-12-09T14:38:39Z
EXPECT_DOUBLE_EQ should compare using a double, not a float.

Also compare against epsilon, not max.

Fixes #28

- - - - -


1 changed file:

- tests/ntpdig/packet_handling.c


Changes:

=====================================
tests/ntpdig/packet_handling.c
=====================================
--- a/tests/ntpdig/packet_handling.c
+++ b/tests/ntpdig/packet_handling.c
@@ -13,8 +13,8 @@
 
 
 #define EXPECT_DOUBLE_EQ(a, b) { \
-	float max = 0.0000000001; \
-	TEST_ASSERT_TRUE(abs(a - b) < max); \
+	static const double epsilon = 1e-10; \
+	TEST_ASSERT_TRUE(abs(a - b) < epsilon); \
 }
 
 static bool LfpEquality(const l_fp* expected, const l_fp* actual) {



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/499c37918dabe8c276ee332f3d1556b0332b39fc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151209/410c1edb/attachment.html>


More information about the vc mailing list