[PATCH 7/7] test: convert all helper functions to use the litest macros

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


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 test/device.c   |  2 +-
 test/log.c      |  4 ++--
 test/misc.c     |  4 ++--
 test/pointer.c  | 28 ++++++++++++++--------------
 test/touchpad.c |  9 +++++----
 5 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/test/device.c b/test/device.c
index 1c277ba..1c7edea 100644
--- a/test/device.c
+++ b/test/device.c
@@ -827,7 +827,7 @@ assert_device_ignored(struct libinput *li, struct input_absinfo *absinfo)
 						 -1);
 	device = libinput_path_add_device(li,
 					  libevdev_uinput_get_devnode(uinput));
-	ck_assert(device == NULL);
+	litest_assert_ptr_null(device);
 	libevdev_uinput_destroy(uinput);
 }
 
diff --git a/test/log.c b/test/log.c
index 139c002..3dbfa90 100644
--- a/test/log.c
+++ b/test/log.c
@@ -58,8 +58,8 @@ simple_log_handler(struct libinput *libinput,
 {
 	log_handler_called++;
 	if (log_handler_context)
-		ck_assert(libinput == log_handler_context);
-	ck_assert(format != NULL);
+		litest_assert_ptr_eq(libinput, log_handler_context);
+	litest_assert_notnull(format);
 }
 
 START_TEST(log_default_priority)
diff --git a/test/misc.c b/test/misc.c
index e9d5462..9eca054 100644
--- a/test/misc.c
+++ b/test/misc.c
@@ -64,7 +64,7 @@ create_simple_test_device(const char *name, ...)
 	};
 
 	evdev = libevdev_new();
-	ck_assert(evdev != NULL);
+	litest_assert_notnull(evdev);
 	libevdev_set_name(evdev, name);
 
 	va_start(args, name);
@@ -82,7 +82,7 @@ create_simple_test_device(const char *name, ...)
 	rc = libevdev_uinput_create_from_device(evdev,
 						LIBEVDEV_UINPUT_OPEN_MANAGED,
 						&uinput);
-	ck_assert_int_eq(rc, 0);
+	litest_assert_int_eq(rc, 0);
 	libevdev_free(evdev);
 
 	return uinput;
diff --git a/test/pointer.c b/test/pointer.c
index a47b95c..eb63c72 100644
--- a/test/pointer.c
+++ b/test/pointer.c
@@ -53,7 +53,7 @@ get_accelerated_motion_event(struct libinput *li)
 		return ptrev;
 	}
 
-	ck_abort_msg("No accelerated pointer motion event found");
+	litest_abort_msg("No accelerated pointer motion event found");
 	return NULL;
 }
 
@@ -90,11 +90,11 @@ test_relative_event(struct litest_device *dev, int dx, int dy)
 	actual_dir = atan2(ev_dx, ev_dy);
 
 	/* Check the length of the motion vector (tolerate 1.0 indifference). */
-	ck_assert(fabs(expected_length) >= actual_length);
+	litest_assert(fabs(expected_length) >= actual_length);
 
 	/* Check the direction of the motion vector (tolerate 2π/4 radians
 	 * indifference). */
-	ck_assert(fabs(expected_dir - actual_dir) < M_PI_2);
+	litest_assert(fabs(expected_dir - actual_dir) < M_PI_2);
 
 	libinput_event_destroy(libinput_event_pointer_get_base_event(ptrev));
 
@@ -112,7 +112,7 @@ disable_button_scrolling(struct litest_device *device)
 					LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
 
 	expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
-	ck_assert_int_eq(status, expected);
+	litest_assert_int_eq(status, expected);
 }
 
 START_TEST(pointer_motion_relative)
@@ -146,16 +146,16 @@ test_absolute_event(struct litest_device *dev, double x, double y)
 	libinput_dispatch(li);
 
 	event = libinput_get_event(li);
-	ck_assert_notnull(event);
-	ck_assert_int_eq(libinput_event_get_type(event), type);
+	litest_assert_notnull(event);
+	litest_assert_int_eq(libinput_event_get_type(event), type);
 
 	ptrev = libinput_event_get_pointer_event(event);
-	ck_assert(ptrev != NULL);
+	litest_assert(ptrev != NULL);
 
 	ex = libinput_event_pointer_get_absolute_x_transformed(ptrev, 100);
 	ey = libinput_event_pointer_get_absolute_y_transformed(ptrev, 100);
-	ck_assert_int_eq((int)(ex + 0.5), (int)x);
-	ck_assert_int_eq((int)(ey + 0.5), (int)y);
+	litest_assert_int_eq((int)(ex + 0.5), (int)x);
+	litest_assert_int_eq((int)(ey + 0.5), (int)y);
 
 	libinput_event_destroy(event);
 }
@@ -192,8 +192,8 @@ test_unaccel_event(struct litest_device *dev, int dx, int dy)
       ev_dx = libinput_event_pointer_get_dx_unaccelerated(ptrev);
       ev_dy = libinput_event_pointer_get_dy_unaccelerated(ptrev);
 
-      ck_assert_int_eq(dx, ev_dx);
-      ck_assert_int_eq(dy, ev_dy);
+      litest_assert_int_eq(dx, ev_dx);
+      litest_assert_int_eq(dy, ev_dy);
 
       libinput_event_destroy(event);
 
@@ -383,10 +383,10 @@ test_wheel_event(struct litest_device *dev, int which, int amount)
 				     axis,
 				     LIBINPUT_POINTER_AXIS_SOURCE_WHEEL);
 
-	ck_assert_int_eq(libinput_event_pointer_get_axis_value(ptrev, axis),
+	litest_assert_int_eq(libinput_event_pointer_get_axis_value(ptrev, axis),
 			 expected);
-	ck_assert_int_eq(libinput_event_pointer_get_axis_value_discrete(ptrev, axis),
-			 discrete);
+	litest_assert_int_eq(libinput_event_pointer_get_axis_value_discrete(ptrev, axis),
+			     discrete);
 	libinput_event_destroy(event);
 }
 
diff --git a/test/touchpad.c b/test/touchpad.c
index ad9e130..27e9ae0 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -2691,13 +2691,14 @@ END_TEST
 static void
 enable_edge_scroll(struct litest_device *dev)
 {
-	enum libinput_config_status status;
+	enum libinput_config_status status, expected;
 	struct libinput_device *device = dev->libinput_device;
 
 	status = libinput_device_config_scroll_set_method(device,
 					  LIBINPUT_CONFIG_SCROLL_EDGE);
-	ck_assert_int_eq(status,
-			 LIBINPUT_CONFIG_STATUS_SUCCESS);
+
+	expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
+	litest_assert_int_eq(status, expected);
 }
 
 START_TEST(touchpad_edge_scroll)
@@ -4020,7 +4021,7 @@ assert_btnevent_from_device(struct litest_device *device,
 	e = libinput_get_event(li);
 	litest_is_button_event(e, button, state);
 
-	ck_assert_ptr_eq(libinput_event_get_device(e), device->libinput_device);
+	litest_assert_ptr_eq(libinput_event_get_device(e), device->libinput_device);
 	libinput_event_destroy(e);
 }
 
-- 
2.3.5



More information about the wayland-devel mailing list