Check for duplicate options in option parser

This commit is contained in:
James Booth
2014-04-14 23:01:57 +01:00
parent 8d77930ece
commit 2419737006
4 changed files with 42 additions and 3 deletions

View File

@@ -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);
}