test: fix a touch test comparing ints to doubles
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 14 Oct 2024 05:20:21 +0000 (15:20 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 15 Oct 2024 02:44:27 +0000 (12:44 +1000)
We were checking doubles for integers but better to check that we're
close to the maximum range without actually being over.

This worked because check typecasts to uint_max_t but let's be explicit
here.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1059>

test/test-touch.c

index a1616408d7d29c2bfc5ac269078d140806ab8490..d5d6fae803044b7ae42d5049f9f15843c2a1993b 100644 (file)
@@ -118,9 +118,11 @@ START_TEST(touch_abs_transform)
 
                tev = libinput_event_get_touch_event(ev);
                fx = libinput_event_touch_get_x_transformed(tev, 1920);
-               ck_assert_int_eq(fx, 1919.0);
+               litest_assert_double_eq_epsilon(fx, 1920.0, 0.1);
+               litest_assert_double_lt(fx, 1920.0);
                fy = libinput_event_touch_get_y_transformed(tev, 720);
-               ck_assert_int_eq(fy, 719.0);
+               litest_assert_double_eq_epsilon(fy, 720.0, 0.1);
+               litest_assert_double_lt(fy, 720.0);
 
                tested = true;