From 33981394aa5d49ed55a48efd6bbfe71628ac2e9a 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 (cherry picked from commit 9d96286a44f90091638fc7f1242530da60849188) --- test/litest.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/litest.h b/test/litest.h index ed23c8a2..1268e104 100644 --- a/test/litest.h +++ b/test/litest.h @@ -404,6 +404,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)) void litest_timeout_tap(void); void litest_timeout_tapndrag(void);