diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-08-27 09:08:51 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-08-28 09:42:17 -0400 |
commit | cb5f8ace79813fd835d4bb396dd693b39b1063e4 (patch) | |
tree | 799252681adfb4a8e2fb4ca226e63d506bec4bfd /src/test/test_confparse.c | |
parent | aa3f0c4788c5cb07243a764589c912a8ed4a26cd (diff) | |
download | tor-cb5f8ace79813fd835d4bb396dd693b39b1063e4.tar.gz tor-cb5f8ace79813fd835d4bb396dd693b39b1063e4.zip |
Tests for config_find_option_name()
Fix a bug in config_find_option_name() where it did not consider
the abbreviations table.
Diffstat (limited to 'src/test/test_confparse.c')
-rw-r--r-- | src/test/test_confparse.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/test_confparse.c b/src/test/test_confparse.c index 1d2e31ab94..f04c412c0e 100644 --- a/src/test/test_confparse.c +++ b/src/test/test_confparse.c @@ -1000,6 +1000,29 @@ test_confparse_list_deprecated(void *arg) config_mgr_free(mgr); } +static void +test_confparse_find_option_name(void *arg) +{ + (void)arg; + config_mgr_t *mgr = config_mgr_new(&test_fmt); + + // exact match + tt_str_op(config_find_option_name(mgr, "u64"), OP_EQ, "u64"); + // case-insensitive match + tt_str_op(config_find_option_name(mgr, "S"), OP_EQ, "s"); + tt_str_op(config_find_option_name(mgr, "linetypea"), OP_EQ, "LineTypeA"); + // prefix match + tt_str_op(config_find_option_name(mgr, "deprec"), OP_EQ, "deprecated_int"); + // explicit abbreviation + tt_str_op(config_find_option_name(mgr, "uint"), OP_EQ, "pos"); + tt_str_op(config_find_option_name(mgr, "UINT"), OP_EQ, "pos"); + // no match + tt_ptr_op(config_find_option_name(mgr, "absent"), OP_EQ, NULL); + + done: + config_mgr_free(mgr); +} + #define CONFPARSE_TEST(name, flags) \ { #name, test_confparse_ ## name, flags, NULL, NULL } @@ -1038,5 +1061,6 @@ struct testcase_t confparse_tests[] = { CONFPARSE_TEST(check_ok_fail, 0), CONFPARSE_TEST(list_vars, 0), CONFPARSE_TEST(list_deprecated, 0), + CONFPARSE_TEST(find_option_name, 0), END_OF_TESTCASES }; |