summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-04-26 12:38:28 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-04-26 12:38:28 +1000
commit3ecdab130a9305518edb9b0f61fa5d74a052d16c (patch)
treedd3fc7eeb5b9e8962fe45413b7e4d485d5c39bda /test
parent97d3ddb070ffb72d011f3eeb8f471b83499e94cc (diff)
parentfe4e2aef0459241234788b7fe4251b17b9a3f4ef (diff)
Merge branch 'wip/touchpad-custom-pressure-values'
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);