mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-20 16:26:22 +00:00
Simplified parse_options to take gchar**
This commit is contained in:
@@ -508,9 +508,7 @@ void
|
||||
parse_options_when_none_returns_empty_hasmap(void **state)
|
||||
{
|
||||
gchar *args[] = { "cmd1", "cmd2", NULL };
|
||||
|
||||
GList *keys = NULL;
|
||||
keys = g_list_append(keys, "opt1");
|
||||
gchar *keys[] = { "opt1", NULL };
|
||||
|
||||
gboolean res = FALSE;
|
||||
|
||||
@@ -521,16 +519,13 @@ parse_options_when_none_returns_empty_hasmap(void **state)
|
||||
assert_true(res);
|
||||
|
||||
options_destroy(options);
|
||||
g_list_free(keys);
|
||||
}
|
||||
|
||||
void
|
||||
parse_options_when_opt1_no_val_sets_error(void **state)
|
||||
{
|
||||
gchar *args[] = { "cmd1", "cmd2", "opt1", NULL };
|
||||
|
||||
GList *keys = NULL;
|
||||
keys = g_list_append(keys, "opt1");
|
||||
gchar *keys[] = { "opt1", NULL };
|
||||
|
||||
gboolean res = TRUE;
|
||||
|
||||
@@ -540,16 +535,13 @@ parse_options_when_opt1_no_val_sets_error(void **state)
|
||||
assert_false(res);
|
||||
|
||||
options_destroy(options);
|
||||
g_list_free(keys);
|
||||
}
|
||||
|
||||
void
|
||||
parse_options_when_one_returns_map(void **state)
|
||||
{
|
||||
gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", NULL };
|
||||
|
||||
GList *keys = NULL;
|
||||
keys = g_list_append(keys, "opt1");
|
||||
gchar *keys[] = { "opt1", NULL };
|
||||
|
||||
gboolean res = FALSE;
|
||||
|
||||
@@ -561,17 +553,13 @@ parse_options_when_one_returns_map(void **state)
|
||||
assert_true(res);
|
||||
|
||||
options_destroy(options);
|
||||
g_list_free(keys);
|
||||
}
|
||||
|
||||
void
|
||||
parse_options_when_opt2_no_val_sets_error(void **state)
|
||||
{
|
||||
gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", NULL };
|
||||
|
||||
GList *keys = NULL;
|
||||
keys = g_list_append(keys, "opt1");
|
||||
keys = g_list_append(keys, "opt2");
|
||||
gchar *keys[] = { "opt1", "opt2", NULL };
|
||||
|
||||
gboolean res = TRUE;
|
||||
|
||||
@@ -581,17 +569,13 @@ parse_options_when_opt2_no_val_sets_error(void **state)
|
||||
assert_false(res);
|
||||
|
||||
options_destroy(options);
|
||||
g_list_free(keys);
|
||||
}
|
||||
|
||||
void
|
||||
parse_options_when_two_returns_map(void **state)
|
||||
{
|
||||
gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", NULL };
|
||||
|
||||
GList *keys = NULL;
|
||||
keys = g_list_append(keys, "opt1");
|
||||
keys = g_list_append(keys, "opt2");
|
||||
gchar *keys[] = { "opt1", "opt2", NULL };
|
||||
|
||||
gboolean res = FALSE;
|
||||
|
||||
@@ -605,18 +589,13 @@ parse_options_when_two_returns_map(void **state)
|
||||
assert_true(res);
|
||||
|
||||
options_destroy(options);
|
||||
g_list_free(keys);
|
||||
}
|
||||
|
||||
void
|
||||
parse_options_when_opt3_no_val_sets_error(void **state)
|
||||
{
|
||||
gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", NULL };
|
||||
|
||||
GList *keys = NULL;
|
||||
keys = g_list_append(keys, "opt1");
|
||||
keys = g_list_append(keys, "opt2");
|
||||
keys = g_list_append(keys, "opt3");
|
||||
gchar *keys[] = { "opt1", "opt2", "opt3", NULL };
|
||||
|
||||
gboolean res = TRUE;
|
||||
|
||||
@@ -626,18 +605,13 @@ parse_options_when_opt3_no_val_sets_error(void **state)
|
||||
assert_false(res);
|
||||
|
||||
options_destroy(options);
|
||||
g_list_free(keys);
|
||||
}
|
||||
|
||||
void
|
||||
parse_options_when_three_returns_map(void **state)
|
||||
{
|
||||
gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", "val3", NULL };
|
||||
|
||||
GList *keys = NULL;
|
||||
keys = g_list_append(keys, "opt1");
|
||||
keys = g_list_append(keys, "opt2");
|
||||
keys = g_list_append(keys, "opt3");
|
||||
gchar *keys[] = { "opt1", "opt2", "opt3", NULL };
|
||||
|
||||
gboolean res = FALSE;
|
||||
|
||||
@@ -653,18 +627,13 @@ parse_options_when_three_returns_map(void **state)
|
||||
assert_true(res);
|
||||
|
||||
options_destroy(options);
|
||||
g_list_free(keys);
|
||||
}
|
||||
|
||||
void
|
||||
parse_options_when_unknown_opt_sets_error(void **state)
|
||||
{
|
||||
gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "oops", "val2", "opt3", "val3", NULL };
|
||||
|
||||
GList *keys = NULL;
|
||||
keys = g_list_append(keys, "opt1");
|
||||
keys = g_list_append(keys, "opt2");
|
||||
keys = g_list_append(keys, "opt3");
|
||||
gchar *keys[] = { "opt1", "opt2", "opt3", NULL };
|
||||
|
||||
gboolean res = TRUE;
|
||||
|
||||
@@ -674,18 +643,13 @@ parse_options_when_unknown_opt_sets_error(void **state)
|
||||
assert_false(res);
|
||||
|
||||
options_destroy(options);
|
||||
g_list_free(keys);
|
||||
}
|
||||
|
||||
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");
|
||||
gchar *keys[] = { "opt1", "opt2", "opt3", NULL };
|
||||
|
||||
gboolean res = TRUE;
|
||||
|
||||
@@ -695,5 +659,4 @@ parse_options_with_duplicated_option_sets_error(void **state)
|
||||
assert_false(res);
|
||||
|
||||
options_destroy(options);
|
||||
g_list_free(keys);
|
||||
}
|
||||
Reference in New Issue
Block a user