[PATCH 4/7] litest: float comparision

Andreas Pokorny andreas.pokorny at canonical.com
Wed Jun 10 07:09:14 PDT 2015


---
 test/litest.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/litest.h b/test/litest.h
index 3a08b6a..0d39dd3 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -428,4 +428,11 @@ void litest_semi_mt_touch_up(struct litest_device *d,
 #define ck_assert_notnull(ptr) ck_assert_ptr_ne(ptr, NULL)
 #endif
 
+#define litest_assert_double_eq(X,Y)  do { \
+  double _litest_x = (X); \
+  double _litest_y = (Y); \
+  ck_assert_msg(fabs(_litest_x - _litest_y) < 1E-5, "Assertion '" #X " == " #Y "' failed: "#X"==%f, "#Y"==%f", _litest_x, _litest_y); \
+} while (0)
+
+
 #endif /* LITEST_H */
-- 
2.1.4



More information about the wayland-devel mailing list