about summary refs log tree commit diff stats
path: root/tests/test_parser.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-04-14 23:01:57 +0100
committerJames Booth <boothj5@gmail.com>2014-04-14 23:01:57 +0100
commit241973700697abb60104c656a0aacfd182eb2316 (patch)
treea9aa0dcf7576a819a835e48d6c35c4c17de32552 /tests/test_parser.c
parent8d77930eceba6841673605f7df5083657a0ecd28 (diff)
downloadprofani-tty-241973700697abb60104c656a0aacfd182eb2316.tar.gz
Check for duplicate options in option parser
Diffstat (limited to 'tests/test_parser.c')
-rw-r--r--tests/test_parser.c20
1 files changed, 20 insertions, 0 deletions
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
@@ -667,4 +667,24 @@ parse_options_when_unknown_opt_sets_error(void **state)
     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