[PATCH 3/7] test: cast to int before integer comparison

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


No effect with the current macros since they'll cast to int for us, but this
will change with the litest_assert macros.

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

diff --git a/test/litest.c b/test/litest.c
index bd4dd81..355c591 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -1125,8 +1125,8 @@ int
 litest_scale(const struct litest_device *d, unsigned int axis, double val)
 {
 	int min, max;
-	ck_assert_int_ge(val, 0);
-	ck_assert_int_le(val, 100);
+	ck_assert_int_ge((int)val, 0);
+	ck_assert_int_le((int)val, 100);
 	ck_assert_int_le(axis, (unsigned int)ABS_Y);
 
 	min = d->interface->min[axis];
@@ -1586,6 +1586,7 @@ litest_assert_scroll(struct libinput *li,
 {
 	struct libinput_event *event, *next_event;
 	struct libinput_event_pointer *ptrev;
+	int value;
 
 	event = libinput_get_event(li);
 	next_event = libinput_get_event(li);
@@ -1595,17 +1596,13 @@ litest_assert_scroll(struct libinput *li,
 		ptrev = litest_is_axis_event(event, axis, 0);
 
 		if (next_event) {
+			value = libinput_event_pointer_get_axis_value(ptrev,
+								      axis);
 			/* Normal scroll event, check dir */
 			if (minimum_movement > 0) {
-				ck_assert_int_ge(
-					libinput_event_pointer_get_axis_value(ptrev,
-									      axis),
-					minimum_movement);
+				ck_assert_int_ge(value, minimum_movement);
 			} else {
-				ck_assert_int_le(
-					libinput_event_pointer_get_axis_value(ptrev,
-									      axis),
-					minimum_movement);
+				ck_assert_int_le(value, minimum_movement);
 			}
 		} else {
 			/* Last scroll event, must be 0 */
diff --git a/test/pointer.c b/test/pointer.c
index 4b93c25..a47b95c 100644
--- a/test/pointer.c
+++ b/test/pointer.c
@@ -154,8 +154,8 @@ test_absolute_event(struct litest_device *dev, double x, double y)
 
 	ex = libinput_event_pointer_get_absolute_x_transformed(ptrev, 100);
 	ey = libinput_event_pointer_get_absolute_y_transformed(ptrev, 100);
-	ck_assert_int_eq(ex + 0.5, x);
-	ck_assert_int_eq(ey + 0.5, y);
+	ck_assert_int_eq((int)(ex + 0.5), (int)x);
+	ck_assert_int_eq((int)(ey + 0.5), (int)y);
 
 	libinput_event_destroy(event);
 }
-- 
2.3.5



More information about the wayland-devel mailing list