From 241973700697abb60104c656a0aacfd182eb2316 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 14 Apr 2014 23:01:57 +0100 Subject: Check for duplicate options in option parser --- tests/test_parser.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/test_parser.c') diff --git a/tests/test_parser.c b/tests/test_parser.c index 1309e8e1..6e1d4cde 100644 --- a/tests/test_parser.c +++ b/tests/test_parser.c @@ -666,5 +666,25 @@ parse_options_when_unknown_opt_sets_error(void **state) assert_null(options); assert_false(res); + options_destroy(options); +} + +void +parse_options_with_duplicated_option_sets_error(void **state) +{ + gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt1", "val3", NULL }; + + GList *keys = NULL; + keys = g_list_append(keys, "opt1"); + keys = g_list_append(keys, "opt2"); + keys = g_list_append(keys, "opt3"); + + gboolean res = TRUE; + + GHashTable *options = parse_options(args, 2, keys, &res); + + assert_null(options); + assert_false(res); + options_destroy(options); } \ No newline at end of file -- cgit 1.4.1-2-gfad0