test: replace manual "almost equal" with the new double epsilon
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 14 Oct 2024 00:14:56 +0000 (10:14 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 15 Oct 2024 02:44:27 +0000 (12:44 +1000)
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1059>

test/test-touch.c

index c6802850e09127b351d976d9c2d4a59b979dbdac..bc9b946a1bf60079a4b1ff258778caf0345f1c21 100644 (file)
@@ -410,28 +410,24 @@ START_TEST(touch_calibration_rotation)
                y = libinput_event_touch_get_y_transformed(tev, height);
 
                /* rounding errors... */
-#define almost_equal(a_, b_) \
-               { ck_assert_int_ge((a_) + 0.5, (b_) - 1); \
-                 ck_assert_int_le((a_) + 0.5, (b_) + 1); }
                switch(i) {
                case 0: /* 0 deg */
-                       almost_equal(x, width * 0.8);
-                       almost_equal(y, height * 0.2);
+                       litest_assert_double_eq_epsilon(x, width * 0.8, 1.0);
+                       litest_assert_double_eq_epsilon(y, height * 0.2, 1.0);
                        break;
                case 1: /* 90 deg cw */
-                       almost_equal(x, width * 0.8);
-                       almost_equal(y, height * 0.8);
+                       litest_assert_double_eq_epsilon(x, width * 0.8, 1.0);
+                       litest_assert_double_eq_epsilon(y, height * 0.8, 1.0);
                        break;
                case 2: /* 180 deg cw */
-                       almost_equal(x, width * 0.2);
-                       almost_equal(y, height * 0.8);
+                       litest_assert_double_eq_epsilon(x, width * 0.2, 1.0);
+                       litest_assert_double_eq_epsilon(y, height * 0.8, 1.0);
                        break;
                case 3: /* 270 deg cw */
-                       almost_equal(x, width * 0.2);
-                       almost_equal(y, height * 0.2);
+                       litest_assert_double_eq_epsilon(x, width * 0.2, 1.0);
+                       litest_assert_double_eq_epsilon(y, height * 0.2, 1.0);
                        break;
                }
-#undef almost_equal
 
                libinput_event_destroy(ev);
                litest_drain_events(li);