From 9d96286a44f90091638fc7f1242530da60849188 Mon Sep 17 00:00:00 2001 From: Stephen Chandler Paul Date: Wed, 11 Jun 2014 20:16:04 -0400 Subject: [PATCH] test: Add litest_assert_double_*() macros Converts two doubles to 24.8 fixed-width integers so assertions can be made with doubles in tests Signed-off-by: Stephen Chandler Paul Reviewed-by: Peter Hutterer --- test/litest.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/litest.h b/test/litest.h index ac8f4497..843c9fb6 100644 --- a/test/litest.h +++ b/test/litest.h @@ -148,6 +148,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)