summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-04-19 13:45:34 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-04-26 12:38:15 +1000
commit8d5f4decb4086e2b7982c3cd1e24afd9c11f551f (patch)
treed2733cf0055bbb6c9d6929dee395c59f197f1715 /test
parent2d96d8f97c94eb5f0633962410129ec9cffc3aae (diff)
touchpad: move the pressure range to a hwdb entry
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test')
-rw-r--r--test/test-misc.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/test-misc.c b/test/test-misc.c
index 3f4b229..5101dcf 100644
--- a/test/test-misc.c
+++ b/test/test-misc.c
@@ -1001,6 +1001,48 @@ START_TEST(calibration_prop_parser)
}
END_TEST
+struct parser_test_pressure_range {
+ char *tag;
+ bool success;
+ int hi, lo;
+};
+
+START_TEST(pressure_range_prop_parser)
+{
+ struct parser_test_pressure_range tests[] = {
+ { "10:8", true, 10, 8 },
+ { "100:-1", true, 100, -1 },
+ { "-203813:-502023", true, -203813, -502023 },
+ { "238492:28210", true, 238492, 28210 },
+ { "none", true, 0, 0 },
+ { "0:0", false, 0, 0 },
+ { "", false, 0, 0 },
+ { "abcd", false, 0, 0 },
+ { "10:30:10", false, 0, 0 },
+ { NULL, false, 0, 0 }
+ };
+ int i;
+ int hi, lo;
+ bool success;
+
+ for (i = 0; tests[i].tag != NULL; i++) {
+ hi = lo = 0xad;
+ success = parse_pressure_range_property(tests[i].tag, &hi, &lo);
+ ck_assert(success == tests[i].success);
+ if (success) {
+ ck_assert_int_eq(hi, tests[i].hi);
+ ck_assert_int_eq(lo, tests[i].lo);
+ } else {
+ ck_assert_int_eq(hi, 0xad);
+ ck_assert_int_eq(lo, 0xad);
+ }
+ }
+
+ success = parse_pressure_range_property(NULL, NULL, NULL);
+ ck_assert(success == false);
+}
+END_TEST
+
START_TEST(time_conversion)
{
ck_assert_int_eq(us(10), 10);
@@ -1275,6 +1317,7 @@ litest_setup_tests_misc(void)
litest_add_no_device("misc:parser", dimension_prop_parser);
litest_add_no_device("misc:parser", reliability_prop_parser);
litest_add_no_device("misc:parser", calibration_prop_parser);
+ litest_add_no_device("misc:parser", pressure_range_prop_parser);
litest_add_no_device("misc:parser", safe_atoi_test);
litest_add_no_device("misc:parser", safe_atod_test);
litest_add_no_device("misc:parser", strsplit_test);