[PATCH libinput 15/23] test: Add litest_assert_double_*() macros

Stephen Chandler Paul thatslyude at gmail.com
Thu Jun 12 20:28:36 PDT 2014


Converts two doubles to 24.8 fixed-width integers so assertions can be made with
doubles in tests

Signed-off-by: Stephen Chandler Paul <thatslyude at gmail.com>
---
 test/litest.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/test/litest.h b/test/litest.h
index ec7026f..90cd68d 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -149,6 +149,23 @@ struct libevdev_uinput * litest_create_uinput_abs_device(const char *name,
 							 struct input_id *id,
 							 const struct input_absinfo *abs,
 							 ...);
+#define litest_assert_double_eq(a_, b_)\
+	ck_assert_int_eq((int)(a_ * 256), (int)(b_ * 256))
+
+#define litest_assert_double_ne(a_, b_)\
+	ck_assert_int_ne((int)(a_ * 256), (int)(b_ * 256))
+
+#define litest_assert_double_lt(a_, b_)\
+	ck_assert_int_lt((int)(a_ * 256), (int)(b_ * 256))
+
+#define litest_assert_double_le(a_, b_)\
+	ck_assert_int_le((int)(a_ * 256), (int)(b_ * 256))
+
+#define litest_assert_double_gt(a_, b_)\
+	ck_assert_int_gt((int)(a_ * 256), (int)(b_ * 256))
+
+#define litest_assert_double_ge(a_, b_)\
+	ck_assert_int_ge((int)(a_ * 256), (int)(b_ * 256))
 
 #ifndef ck_assert_notnull
 #define ck_assert_notnull(ptr) ck_assert_ptr_ne(ptr, NULL)
-- 
1.8.5.5



More information about the wayland-devel mailing list