diff options
author | José Expósito <jose.exposito89@gmail.com> | 2021-09-12 17:09:20 +0200 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2021-09-12 21:16:32 +0000 |
commit | dbcb003c5e579a8dcbcb622f230be4f3672ea3c8 (patch) | |
tree | 06751c238a5c69c991bab03fb6dd18bd3c5893a6 /test/test-utils.c | |
parent | d8088176149a6086927eb765a6e617cf0041ec10 (diff) | |
download | libinput-dbcb003c5e579a8dcbcb622f230be4f3672ea3c8.tar.gz |
util: add a function to parse bool properties
Move the logic used to parse boolean quirks and udev flags to a common
function in utils.
Refactor, no functional changes.
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Diffstat (limited to 'test/test-utils.c')
-rw-r--r-- | test/test-utils.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/test-utils.c b/test/test-utils.c index bdefd794..6d31c1d5 100644 --- a/test/test-utils.c +++ b/test/test-utils.c @@ -471,6 +471,38 @@ START_TEST(range_prop_parser) } END_TEST +START_TEST(boolean_prop_parser) +{ + struct parser_test_range { + char *tag; + bool success; + bool b; + } tests[] = { + { "0", true, false }, + { "1", true, true }, + { "-1", false, false }, + { "2", false, false }, + { "abcd", false, false }, + { NULL, false, false } + }; + int i; + bool success, b; + + for (i = 0; tests[i].tag != NULL; i++) { + b = false; + success = parse_boolean_property(tests[i].tag, &b); + ck_assert(success == tests[i].success); + if (success) + ck_assert_int_eq(b, tests[i].b); + else + ck_assert_int_eq(b, false); + } + + success = parse_boolean_property(NULL, NULL); + ck_assert(success == false); +} +END_TEST + START_TEST(evcode_prop_parser) { struct parser_test_tuple { @@ -1438,6 +1470,7 @@ litest_utils_suite(void) tcase_add_test(tc, reliability_prop_parser); tcase_add_test(tc, calibration_prop_parser); tcase_add_test(tc, range_prop_parser); + tcase_add_test(tc, boolean_prop_parser); tcase_add_test(tc, evcode_prop_parser); tcase_add_test(tc, input_prop_parser); tcase_add_test(tc, evdev_abs_parser); |