[PATCH 2/7] test: don't use enum values in ck_assert macros directly

Peter Hutterer peter.hutterer at who-t.net
Thu May 7 22:57:45 PDT 2015


Unfortunately, typeof(enum something) != typeof(ENUM_VALUE) and produces a
-Wsign-compare warning

Preemptively fix this, it'll show up in the upcoming litest_asssert macros
otherwise.

This fix only applies to helper functions, tests themselves wont (yet) be
switched to the new macros and don't need fixing.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/litest.c  |  4 ++--
 test/pointer.c | 10 ++++++----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/test/litest.c b/test/litest.c
index 7764b8b..bd4dd81 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -1462,10 +1462,10 @@ litest_is_button_event(struct libinput_event *event,
 		       enum libinput_button_state state)
 {
 	struct libinput_event_pointer *ptrev;
+	enum libinput_event_type type = LIBINPUT_EVENT_POINTER_BUTTON;
 
 	ck_assert(event != NULL);
-	ck_assert_int_eq(libinput_event_get_type(event),
-			 LIBINPUT_EVENT_POINTER_BUTTON);
+	ck_assert_int_eq(libinput_event_get_type(event), type);
 	ptrev = libinput_event_get_pointer_event(event);
 	ck_assert_int_eq(libinput_event_pointer_get_button(ptrev),
 			 button);
diff --git a/test/pointer.c b/test/pointer.c
index 43c21ba..4b93c25 100644
--- a/test/pointer.c
+++ b/test/pointer.c
@@ -105,12 +105,14 @@ static void
 disable_button_scrolling(struct litest_device *device)
 {
 	struct libinput_device *dev = device->libinput_device;
-	enum libinput_config_status status;
+	enum libinput_config_status status,
+				    expected;
 
 	status = libinput_device_config_scroll_set_method(dev,
 					LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
 
-	ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
+	expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
+	ck_assert_int_eq(status, expected);
 }
 
 START_TEST(pointer_motion_relative)
@@ -138,14 +140,14 @@ test_absolute_event(struct litest_device *dev, double x, double y)
 	struct libinput_event *event;
 	struct libinput_event_pointer *ptrev;
 	double ex, ey;
+	enum libinput_event_type type = LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE;
 
 	litest_touch_down(dev, 0, x, y);
 	libinput_dispatch(li);
 
 	event = libinput_get_event(li);
 	ck_assert_notnull(event);
-	ck_assert_int_eq(libinput_event_get_type(event),
-			 LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
+	ck_assert_int_eq(libinput_event_get_type(event), type);
 
 	ptrev = libinput_event_get_pointer_event(event);
 	ck_assert(ptrev != NULL);
-- 
2.3.5



More information about the wayland-devel mailing list