[PATCH v2 libinput 2/2] test: Add test for mouse dpi tag parser
Derek Foreman
derekf at osg.samsung.com
Tue Nov 25 09:46:43 PST 2014
Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
test/misc.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/test/misc.c b/test/misc.c
index 4ed9dce..c8ac51f 100644
--- a/test/misc.c
+++ b/test/misc.c
@@ -548,6 +548,43 @@ START_TEST(ratelimit_helpers)
}
END_TEST
+struct parser_test {
+ char *tag;
+ int expected_dpi;
+};
+
+START_TEST(dpi_parser)
+{
+ struct parser_test tests[] = {
+ { "450 *1800 3200", 1800 },
+ { "*450 1800 3200", 450 },
+ { "450 1800 *3200", 3200 },
+ { "450 1800 *failboat", 0 },
+ { "0 450 1800 *3200", 0 },
+ { "450 at 37 1800 at 12 *3200 at 6", 3200 },
+ { "450 at 125 1800 at 125 *3200 at 125 ", 3200 },
+ { "450 at 125 *1800 at 125 3200 at 125", 1800 },
+ { "*this @string fails", 0 },
+ { "12 at 34 *45@", 0 },
+ { " * 12, 450, 800", 0 },
+ { " *12, 450, 800", 12 },
+ { "*12, *450, 800", 12 },
+ { "*-23412, 450, 800", 0 },
+ { "112 at 125, 450 at 125, 800 at 125, 900 at -125", 0 },
+ { "", 0 },
+ { " ", 0 },
+ { "* ", 0 },
+ { NULL }
+ };
+ int i, dpi;
+
+ for (i = 0; tests[i].tag != NULL; i++) {
+ dpi = parse_mouse_dpi_property(tests[i].tag);
+ ck_assert(dpi == tests[i].expected_dpi);
+ }
+}
+END_TEST
+
int main (int argc, char **argv) {
litest_add_no_device("events:conversion", event_conversion_device_notify);
litest_add_no_device("events:conversion", event_conversion_pointer);
@@ -560,6 +597,7 @@ int main (int argc, char **argv) {
litest_add_no_device("misc:matrix", matrix_helpers);
litest_add_no_device("misc:ratelimit", ratelimit_helpers);
+ litest_add_no_device("misc:dpi parser", dpi_parser);
return litest_run(argc, argv);
}
--
2.1.3
More information about the wayland-devel
mailing list