gchar *help_variants[] = { "--help", "--help-all", "--help-test" };
GOptionEntry main_entries[] = {
- { "main-switch", 0,
- G_OPTION_FLAG_NO_ARG,
+ { "main-switch", 0, 0,
G_OPTION_ARG_NONE, NULL,
"A switch that is in the main group", NULL },
{ NULL }
};
GOptionEntry group_entries[] = {
- { "test-switch", 0,
- G_OPTION_FLAG_NO_ARG,
+ { "test-switch", 0, 0,
G_OPTION_ARG_NONE, NULL,
"A switch that is in the test group", NULL },
{ NULL }
g_setenv ("LANG", "C", TRUE);
g_option_context_parse (options, &argc, &argv, &error);
+ g_option_context_free (options);
exit(0);
}
else
g_test_trap_assert_stdout_unmatched ("*--help-test*");
}
}
+
+ g_option_context_free (options);
}
}
gboolean ignore_test2_boolean;
gchar *ignore_test3_string;
-gchar **
+static gchar **
split_string (const char *str, int *argc)
{
gchar **argv;
return argv;
}
-gchar *
+static gchar *
join_stringv (int argc, char **argv)
{
int i;
}
/* Performs a shallow copy */
-char **
+static char **
copy_stringv (char **argv, int argc)
{
return g_memdup (argv, sizeof (char *) * (argc + 1));
}
+static void
+check_identical_stringv (gchar **before, gchar **after)
+{
+ guint i;
+
+ /* Not only is it the same string... */
+ for (i = 0; before[i] != NULL; i++)
+ g_assert_cmpstr (before[i], ==, after[i]);
+
+ /* ... it is actually the same pointer */
+ for (i = 0; before[i] != NULL; i++)
+ g_assert (before[i] == after[i]);
+
+ g_assert (after[i] == NULL);
+}
+
static gboolean
error_test1_pre_parse (GOptionContext *context,
return FALSE;
}
-void
+static void
error_test1 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionGroup *main_group;
GOptionEntry entries [] =
/* Now try parsing */
argv = split_string ("program --test 20", &argc);
+ argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
g_assert (retval == FALSE);
+ g_assert (error != NULL);
+ /* An error occurred, so argv has not been changed */
+ check_identical_stringv (argv_copy, argv);
+ g_clear_error (&error);
/* On failure, values should be reset */
g_assert (error_test1_int == 0x12345678);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
return FALSE;
}
-void
+static void
error_test2 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionGroup *main_group;
GOptionEntry entries [] =
/* Now try parsing */
argv = split_string ("program --test bar", &argc);
+ argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
- g_error_free (error);
g_assert (retval == FALSE);
+ g_assert (error != NULL);
+ check_identical_stringv (argv_copy, argv);
+ g_clear_error (&error);
g_assert (strcmp (error_test2_string, "foo") == 0);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
return FALSE;
}
-void
+static void
error_test3 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionGroup *main_group;
GOptionEntry entries [] =
/* Now try parsing */
argv = split_string ("program --test", &argc);
+ argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
- g_error_free (error);
g_assert (retval == FALSE);
+ g_assert (error != NULL);
+ check_identical_stringv (argv_copy, argv);
+ g_clear_error (&error);
g_assert (!error_test3_boolean);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
static void
-assert_no_error (GError *error)
-{
- if (error)
- {
- fprintf (stderr, "unexpected error: %s, %d, %s\n", g_quark_to_string (error->domain), error->code, error->message);
- exit (1);
- }
-}
-
-void
arg_test1 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "test", 0, 0, G_OPTION_ARG_INT, &arg_test1_int, NULL, NULL },
/* Now try parsing */
argv = split_string ("program --test 20 --test 30", &argc);
+ argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
g_assert (arg_test1_int == 30);
- g_strfreev (argv);
+ /* We free all of the strings in a copy of argv, because now argv is a
+ * subset - some have been removed in-place
+ */
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
arg_test2 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "test", 0, 0, G_OPTION_ARG_STRING, &arg_test2_string, NULL, NULL },
/* Now try parsing */
argv = split_string ("program --test foo --test bar", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
g_assert (strcmp (arg_test2_string, "bar") == 0);
g_free (arg_test2_string);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
arg_test3 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "test", 0, 0, G_OPTION_ARG_FILENAME, &arg_test3_filename, NULL, NULL },
/* Now try parsing */
argv = split_string ("program --test foo.txt", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
g_assert (strcmp (arg_test3_filename, "foo.txt") == 0);
g_free (arg_test3_filename);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
arg_test4 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
+ gchar **argv_copy;
gchar **argv;
int argc;
GOptionEntry entries [] =
/* Now try parsing */
argv = split_string ("program --test 20.0 --test 30.03", &argc);
+ argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
g_assert (arg_test4_double == 30.03);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
arg_test5 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
char *old_locale, *current_locale;
const char *locale = "de_DE";
/* Now try parsing */
argv = split_string ("program --test 20,0 --test 30,03", &argc);
+ argv_copy = copy_stringv (argv, argc);
/* set it to some locale that uses commas instead of decimal points */
}
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
setlocale (LC_NUMERIC, old_locale);
g_free (old_locale);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
arg_test6 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "test", 0, 0, G_OPTION_ARG_INT64, &arg_test6_int64, NULL, NULL },
/* Now try parsing */
argv = split_string ("program --test 4294967297 --test 4294967296 --test2 0xfffffffff", &argc);
+ argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
g_assert (arg_test6_int64 == G_GINT64_CONSTANT(4294967296));
g_assert (arg_test6_int64_2 == G_GINT64_CONSTANT(0xfffffffff));
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
return TRUE;
}
-void
+static void
callback_test1 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "test", 0, 0, G_OPTION_ARG_CALLBACK, callback_parse1, NULL, NULL },
/* Now try parsing */
argv = split_string ("program --test foo.txt", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
g_assert (strcmp (callback_test1_string, "foo.txt") == 0);
g_free (callback_test1_string);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
return TRUE;
}
-void
+static void
callback_test2 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "test", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, callback_parse2, NULL, NULL },
/* Now try parsing */
argv = split_string ("program --test --test", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test2_int == 2);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
return TRUE;
}
-void
+static void
callback_test_optional_1 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "test", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
/* Now try parsing */
argv = split_string ("program --test foo.txt", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
g_assert (strcmp (callback_test_optional_string, "foo.txt") == 0);
g_assert (callback_test_optional_boolean);
g_free (callback_test_optional_string);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
callback_test_optional_2 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "test", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
/* Now try parsing */
argv = split_string ("program --test", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
g_assert (callback_test_optional_boolean);
g_free (callback_test_optional_string);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
callback_test_optional_3 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
+ gchar **argv_copy;
gchar **argv;
int argc;
GOptionEntry entries [] =
/* Now try parsing */
argv = split_string ("program -t foo.txt", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
g_assert (strcmp (callback_test_optional_string, "foo.txt") == 0);
g_assert (callback_test_optional_boolean);
g_free (callback_test_optional_string);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
callback_test_optional_4 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "test", 't', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
/* Now try parsing */
argv = split_string ("program -t", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
g_assert (callback_test_optional_boolean);
g_free (callback_test_optional_string);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
callback_test_optional_5 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "dummy", 'd', 0, G_OPTION_ARG_NONE, &dummy, NULL },
/* Now try parsing */
argv = split_string ("program --test --dummy", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
g_assert (callback_test_optional_boolean);
g_free (callback_test_optional_string);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
callback_test_optional_6 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "dummy", 'd', 0, G_OPTION_ARG_NONE, &dummy, NULL },
/* Now try parsing */
argv = split_string ("program -t -d", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
g_assert (callback_test_optional_boolean);
g_free (callback_test_optional_string);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
callback_test_optional_7 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "dummy", 'd', 0, G_OPTION_ARG_NONE, &dummy, NULL },
/* Now try parsing */
argv = split_string ("program -td", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
g_assert (callback_test_optional_boolean);
g_free (callback_test_optional_string);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
callback_test_optional_8 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "dummy", 'd', 0, G_OPTION_ARG_NONE, &dummy, NULL },
/* Now try parsing */
argv = split_string ("program -dt foo.txt", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string);
g_assert (callback_test_optional_boolean);
g_free (callback_test_optional_string);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
return TRUE;
}
-void
+static void
callback_remaining_test1 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_CALLBACK, callback_remaining_test1_callback, NULL, NULL },
/* Now try parsing */
argv = split_string ("program foo.txt blah.txt", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
g_assert (callback_remaining_args->len == 2);
g_ptr_array_foreach (callback_remaining_args, (GFunc) g_free, NULL);
g_ptr_array_free (callback_remaining_args, TRUE);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "error", 0, 0, G_OPTION_ARG_CALLBACK, callback_error, NULL, NULL },
/* Now try parsing */
argv = split_string ("program --error value", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
g_assert_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE);
g_assert (retval == FALSE);
+ check_identical_stringv (argv_copy, argv);
g_option_context_free (context);
g_clear_error (&error);
+ g_strfreev (argv_copy);
+ g_free (argv);
/* And again, this time with a no-arg variant */
context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, entries, NULL);
argv = split_string ("program --error-no-arg", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
g_assert_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE);
g_assert (retval == FALSE);
+ check_identical_stringv (argv_copy, argv);
g_option_context_free (context);
g_clear_error (&error);
+ g_strfreev (argv_copy);
+ g_free (argv);
/* And again, this time with a optional arg variant, with argument */
context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, entries, NULL);
argv = split_string ("program --error-optional-arg value", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
g_assert_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE);
g_assert (retval == FALSE);
+ check_identical_stringv (argv_copy, argv);
g_option_context_free (context);
g_clear_error (&error);
+ g_strfreev (argv_copy);
+ g_free (argv);
/* And again, this time with a optional arg variant, without argument */
context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, entries, NULL);
argv = split_string ("program --error-optional-arg", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
g_assert_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE);
g_assert (retval == FALSE);
+ check_identical_stringv (argv_copy, argv);
g_option_context_free (context);
g_clear_error (&error);
+ g_strfreev (argv_copy);
+ g_free (argv);
}
-void
+static void
ignore_test1 (void)
{
GOptionContext *context;
argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
g_option_context_free (context);
}
-void
+static void
ignore_test2 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
gchar *arg;
GOptionEntry entries [] =
/* Now try parsing */
argv = split_string ("program -test", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
g_assert (strcmp (arg, "program -es") == 0);
g_free (arg);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
ignore_test3 (void)
{
GOptionContext *context;
argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
}
void
-array_test1 (void)
+static array_test1 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] =
{ { "test", 0, 0, G_OPTION_ARG_STRING_ARRAY, &array_test1_array, NULL, NULL },
/* Now try parsing */
argv = split_string ("program --test foo --test bar", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
g_strfreev (array_test1_array);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
add_test1 (void)
{
GOptionContext *context;
g_option_context_free (context);
}
-void
-empty_test1 (void)
-{
- GOptionContext *context;
- GOptionEntry entries [] =
- { { NULL } };
- char *prgname;
-
- g_set_prgname (NULL);
- context = g_option_context_new (NULL);
-
- g_option_context_add_main_entries (context, entries, NULL);
-
- g_option_context_parse (context, NULL, NULL, NULL);
-
- prgname = g_get_prgname ();
- g_assert (prgname && strcmp (prgname, "<unknown>") == 0);
-
- g_option_context_free (context);
-}
-
-void
+static void
empty_test2 (void)
{
GOptionContext *context;
g_option_context_free (context);
}
-void
+static void
empty_test3 (void)
{
GOptionContext *context;
}
/* check that non-option arguments are left in argv by default */
-void
+static void
rest_test1 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] = {
{ "test", 0, 0, G_OPTION_ARG_NONE, &ignore_test1_boolean, NULL, NULL },
/* Now try parsing */
argv = split_string ("program foo --test bar", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
g_assert (strcmp (argv[2], "bar") == 0);
g_assert (argv[3] == NULL);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
/* check that -- works */
-void
+static void
rest_test2 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] = {
{ "test", 0, 0, G_OPTION_ARG_NONE, &ignore_test1_boolean, NULL, NULL },
/* Now try parsing */
argv = split_string ("program foo --test -- -bar", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
g_assert (strcmp (argv[3], "-bar") == 0);
g_assert (argv[4] == NULL);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
/* check that -- stripping works */
-void
+static void
rest_test2a (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] = {
{ "test", 0, 0, G_OPTION_ARG_NONE, &ignore_test1_boolean, NULL, NULL },
/* Now try parsing */
argv = split_string ("program foo --test -- bar", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
g_assert (strcmp (argv[2], "bar") == 0);
g_assert (argv[3] == NULL);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
rest_test2b (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] = {
{ "test", 0, 0, G_OPTION_ARG_NONE, &ignore_test1_boolean, NULL, NULL },
/* Now try parsing */
argv = split_string ("program foo --test -bar --", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
g_assert (strcmp (argv[2], "-bar") == 0);
g_assert (argv[3] == NULL);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
rest_test2c (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] = {
{ "test", 0, 0, G_OPTION_ARG_NONE, &ignore_test1_boolean, NULL, NULL },
/* Now try parsing */
argv = split_string ("program --test foo -- bar", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
g_assert (strcmp (argv[2], "bar") == 0);
g_assert (argv[3] == NULL);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
rest_test2d (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] = {
{ "test", 0, 0, G_OPTION_ARG_NONE, &ignore_test1_boolean, NULL, NULL },
/* Now try parsing */
argv = split_string ("program --test -- -bar", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
g_assert (strcmp (argv[2], "-bar") == 0);
g_assert (argv[3] == NULL);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
/* check that G_OPTION_REMAINING collects non-option arguments */
-void
+static void
rest_test3 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] = {
{ "test", 0, 0, G_OPTION_ARG_NONE, &ignore_test1_boolean, NULL, NULL },
/* Now try parsing */
argv = split_string ("program foo --test bar", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
g_assert (array_test1_array[2] == NULL);
g_strfreev (array_test1_array);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
/* check that G_OPTION_REMAINING and -- work together */
-void
+static void
rest_test4 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] = {
{ "test", 0, 0, G_OPTION_ARG_NONE, &ignore_test1_boolean, NULL, NULL },
/* Now try parsing */
argv = split_string ("program foo --test -- -bar", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
g_assert (array_test1_array[2] == NULL);
g_strfreev (array_test1_array);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
/* test that G_OPTION_REMAINING works with G_OPTION_ARG_FILENAME_ARRAY */
-void
+static void
rest_test5 (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] = {
{ "test", 0, 0, G_OPTION_ARG_NONE, &ignore_test1_boolean, NULL, NULL },
/* Now try parsing */
argv = split_string ("program foo --test bar", &argc);
-
+ argv_copy = copy_stringv (argv, argc);
+
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
/* Check array */
g_assert (array_test1_array[2] == NULL);
g_strfreev (array_test1_array);
-
- g_strfreev (argv);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
unknown_short_test (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
GOptionEntry entries [] = { { NULL } };
/* Now try parsing */
argv = split_string ("program -0", &argc);
+ argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
g_assert (!retval);
+ g_assert (error != NULL);
+ g_clear_error (&error);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
/* test that lone dashes are treated as non-options */
-void lonely_dash_test (void)
+static void
+lonely_dash_test (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
g_test_bug ("168008");
/* Now try parsing */
argv = split_string ("program -", &argc);
+ argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
- assert_no_error (error);
+ g_assert_no_error (error);
g_assert (retval);
g_assert (argv[1] && strcmp (argv[1], "-") == 0);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
-void
+static void
missing_arg_test (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
+ gchar **argv_copy;
int argc;
gchar *arg = NULL;
GOptionEntry entries [] =
/* Now try parsing */
argv = split_string ("program --test", &argc);
+ argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
g_assert (retval == FALSE);
+ g_assert (error != NULL);
+ /* An error occurred, so argv has not been changed */
+ check_identical_stringv (argv_copy, argv);
g_clear_error (&error);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
/* Try parsing again */
- argv = split_string ("program --t", &argc);
+ argv = split_string ("program -t", &argc);
+ argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
g_assert (retval == FALSE);
+ g_assert (error != NULL);
+ /* An error occurred, so argv has not been changed */
+ check_identical_stringv (argv_copy, argv);
+ g_clear_error (&error);
- g_strfreev (argv);
+ g_strfreev (argv_copy);
+ g_free (argv);
g_option_context_free (context);
}
+static gchar *test_arg;
+
+static gboolean cb (const gchar *option_name,
+ const gchar *value,
+ gpointer data,
+ GError **error)
+{
+ test_arg = g_strdup (value);
+ return TRUE;
+}
+
+static void
+dash_arg_test (void)
+{
+ GOptionContext *context;
+ gboolean retval;
+ GError *error = NULL;
+ gchar **argv;
+ gchar **argv_copy;
+ int argc;
+ gboolean argb = FALSE;
+ GOptionEntry entries [] =
+ { { "test", 't', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, cb, NULL, NULL },
+ { "three", '3', 0, G_OPTION_ARG_NONE, &argb, NULL, NULL },
+ { NULL } };
+
+ g_test_bug ("577638");
+
+ context = g_option_context_new (NULL);
+ g_option_context_add_main_entries (context, entries, NULL);
+
+ /* Now try parsing */
+ argv = split_string ("program --test=-3", &argc);
+ argv_copy = copy_stringv (argv, argc);
+
+ test_arg = NULL;
+ error = NULL;
+ retval = g_option_context_parse (context, &argc, &argv, &error);
+ g_assert (retval);
+ g_assert_no_error (error);
+ g_assert_cmpstr (test_arg, ==, "-3");
+
+ g_strfreev (argv_copy);
+ g_free (argv);
+ g_free (test_arg);
+ test_arg = NULL;
+
+ /* Try parsing again */
+ argv = split_string ("program --test -3", &argc);
+ argv_copy = copy_stringv (argv, argc);
+
+ error = NULL;
+ retval = g_option_context_parse (context, &argc, &argv, &error);
+ g_assert_no_error (error);
+ g_assert (retval);
+ g_assert_cmpstr (test_arg, ==, NULL);
+
+ g_option_context_free (context);
+ g_strfreev (argv_copy);
+ g_free (argv);
+}
+
+static void
+test_basic (void)
+{
+ GOptionContext *context;
+ gchar *arg = NULL;
+ GOptionEntry entries [] =
+ { { "test", 't', 0, G_OPTION_ARG_STRING, &arg, NULL, NULL },
+ { NULL } };
+
+ context = g_option_context_new (NULL);
+ g_option_context_add_main_entries (context, entries, NULL);
+
+ g_assert (g_option_context_get_help_enabled (context));
+ g_assert (!g_option_context_get_ignore_unknown_options (context));
+ g_assert_cmpstr (g_option_context_get_summary (context), ==, NULL);
+ g_assert_cmpstr (g_option_context_get_description (context), ==, NULL);
+
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_ignore_unknown_options (context, TRUE);
+ g_option_context_set_summary (context, "summary");
+ g_option_context_set_description(context, "description");
+
+ g_assert (!g_option_context_get_help_enabled (context));
+ g_assert (g_option_context_get_ignore_unknown_options (context));
+ g_assert_cmpstr (g_option_context_get_summary (context), ==, "summary");
+ g_assert_cmpstr (g_option_context_get_description (context), ==, "description");
+
+ g_option_context_free (context);
+}
+
+static void
+test_main_group (void)
+{
+ GOptionContext *context;
+ GOptionGroup *group;
+
+ context = g_option_context_new (NULL);
+ g_assert (g_option_context_get_main_group (context) == NULL);
+ group = g_option_group_new ("name", "description", "hlep", NULL, NULL);
+ g_option_context_add_group (context, group);
+ g_assert (g_option_context_get_main_group (context) == NULL);
+ group = g_option_group_new ("name", "description", "hlep", NULL, NULL);
+ g_option_context_set_main_group (context, group);
+ g_assert (g_option_context_get_main_group (context) == group);
+
+ g_option_context_free (context);
+}
+
+static gboolean error_func_called = FALSE;
+
+static void
+error_func (GOptionContext *context,
+ GOptionGroup *group,
+ gpointer data,
+ GError **error)
+{
+ g_assert_cmpint (GPOINTER_TO_INT(data), ==, 1234);
+ error_func_called = TRUE;
+}
+
+static void
+test_error_hook (void)
+{
+ GOptionContext *context;
+ gchar *arg = NULL;
+ GOptionEntry entries [] =
+ { { "test", 't', 0, G_OPTION_ARG_STRING, &arg, NULL, NULL },
+ { NULL } };
+ GOptionGroup *group;
+ gchar **argv;
+ gchar **argv_copy;
+ gint argc;
+ gboolean retval;
+ GError *error = NULL;
+
+ context = g_option_context_new (NULL);
+ group = g_option_group_new ("name", "description", "hlep", GINT_TO_POINTER(1234), NULL);
+ g_option_group_add_entries (group, entries);
+ g_option_context_set_main_group (context, group);
+ g_option_group_set_error_hook (g_option_context_get_main_group (context),
+ error_func);
+
+ argv = split_string ("program --test", &argc);
+ argv_copy = copy_stringv (argv, argc);
+
+ retval = g_option_context_parse (context, &argc, &argv, &error);
+ g_assert (retval == FALSE);
+ g_assert (error != NULL);
+ /* An error occurred, so argv has not been changed */
+ check_identical_stringv (argv_copy, argv);
+ g_clear_error (&error);
+
+ g_assert (error_func_called);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
+ g_option_context_free (context);
+}
+
+static void
+flag_reverse_string (void)
+{
+ if (!g_test_undefined ())
+ return;
+
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ GOptionContext *context;
+ gchar *arg = NULL;
+ GOptionEntry entries [] =
+ { { "test", 't', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_STRING, &arg, NULL, NULL },
+ { NULL } };
+ gchar **argv;
+ gint argc;
+ gboolean retval;
+ GError *error = NULL;
+
+ context = g_option_context_new (NULL);
+ g_option_context_add_main_entries (context, entries, NULL);
+
+ argv = split_string ("program --test bla", &argc);
+
+ retval = g_option_context_parse (context, &argc, &argv, &error);
+ g_assert (retval == FALSE);
+ g_clear_error (&error);
+ g_strfreev (argv);
+ g_option_context_free (context);
+ exit (0);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*ignoring reverse flag*");
+}
+
+static void
+flag_optional_int (void)
+{
+ if (!g_test_undefined ())
+ return;
+
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ GOptionContext *context;
+ gint arg = 0;
+ GOptionEntry entries [] =
+ { { "test", 't', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_INT, &arg, NULL, NULL },
+ { NULL } };
+ gchar **argv;
+ gint argc;
+ gboolean retval;
+ GError *error = NULL;
+
+ context = g_option_context_new (NULL);
+ g_option_context_add_main_entries (context, entries, NULL);
+
+ argv = split_string ("program --test 5", &argc);
+
+ retval = g_option_context_parse (context, &argc, &argv, &error);
+ g_assert (retval == FALSE);
+ g_clear_error (&error);
+ g_strfreev (argv);
+ g_option_context_free (context);
+ exit (0);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*ignoring no-arg, optional-arg or filename flags*");
+}
int
main (int argc,
char *argv[])
g_test_init (&argc, &argv, NULL);
g_test_bug_base ("http://bugzilla.gnome.org/");
- g_test_add_func ("/group/captions", group_captions);
+
+ g_test_add_func ("/option/basic", test_basic);
+ g_test_add_func ("/option/group/captions", group_captions);
+ g_test_add_func ("/option/group/main", test_main_group);
+ g_test_add_func ("/option/group/error-hook", test_error_hook);
/* Test that restoration on failure works */
- g_test_add_func ("/restoration/int", error_test1);
- g_test_add_func ("/restoration/string", error_test2);
- g_test_add_func ("/restoration/boolean", error_test3);
-
+ g_test_add_func ("/option/restoration/int", error_test1);
+ g_test_add_func ("/option/restoration/string", error_test2);
+ g_test_add_func ("/option/restoration/boolean", error_test3);
+
/* Test that special argument parsing works */
- g_test_add_func ("/arg/repetition/int", arg_test1);
- g_test_add_func ("/arg/repetition/string", arg_test2);
- g_test_add_func ("/arg/repetition/filename", arg_test3);
- g_test_add_func ("/arg/repetition/double", arg_test4);
- g_test_add_func ("/arg/repetition/locale", arg_test5);
- g_test_add_func ("/arg/repetition/int64", arg_test6);
+ g_test_add_func ("/option/arg/repetition/int", arg_test1);
+ g_test_add_func ("/option/arg/repetition/string", arg_test2);
+ g_test_add_func ("/option/arg/repetition/filename", arg_test3);
+ g_test_add_func ("/option/arg/repetition/double", arg_test4);
+ g_test_add_func ("/option/arg/repetition/locale", arg_test5);
+ g_test_add_func ("/option/arg/repetition/int64", arg_test6);
/* Test string arrays */
- g_test_add_func ("/arg/array/string", array_test1);
+ g_test_add_func ("/option/arg/array/string", array_test1);
/* Test callback args */
- g_test_add_func ("/arg/callback/string", callback_test1);
- g_test_add_func ("/arg/callback/count", callback_test2);
+ g_test_add_func ("/option/arg/callback/string", callback_test1);
+ g_test_add_func ("/option/arg/callback/count", callback_test2);
/* Test optional arg flag for callback */
- g_test_add_func ("/arg/callback/optional1", callback_test_optional_1);
- g_test_add_func ("/arg/callback/optional2", callback_test_optional_2);
- g_test_add_func ("/arg/callback/optional3", callback_test_optional_3);
- g_test_add_func ("/arg/callback/optional4", callback_test_optional_4);
- g_test_add_func ("/arg/callback/optional5", callback_test_optional_5);
- g_test_add_func ("/arg/callback/optional6", callback_test_optional_6);
- g_test_add_func ("/arg/callback/optional7", callback_test_optional_7);
- g_test_add_func ("/arg/callback/optional8", callback_test_optional_8);
+ g_test_add_func ("/option/arg/callback/optional1", callback_test_optional_1);
+ g_test_add_func ("/option/arg/callback/optional2", callback_test_optional_2);
+ g_test_add_func ("/option/arg/callback/optional3", callback_test_optional_3);
+ g_test_add_func ("/option/arg/callback/optional4", callback_test_optional_4);
+ g_test_add_func ("/option/arg/callback/optional5", callback_test_optional_5);
+ g_test_add_func ("/option/arg/callback/optional6", callback_test_optional_6);
+ g_test_add_func ("/option/arg/callback/optional7", callback_test_optional_7);
+ g_test_add_func ("/option/arg/callback/optional8", callback_test_optional_8);
/* Test callback with G_OPTION_REMAINING */
- g_test_add_func ("/arg/remaining/callback", callback_remaining_test1);
-
+ g_test_add_func ("/option/arg/remaining/callback", callback_remaining_test1);
+
/* Test callbacks which return FALSE */
- g_test_add_func ("/arg/remaining/callback-false", callback_returns_false);
-
- /* Test ignoring options */
- g_test_add_func ("/arg/ignore/long", ignore_test1);
- g_test_add_func ("/arg/ignore/short", ignore_test2);
- g_test_add_func ("/arg/ignore/arg", ignore_test3);
+ g_test_add_func ("/option/arg/remaining/callback-false", callback_returns_false);
- g_test_add_func ("/context/add", add_test1);
+ /* Test ignoring options */
+ g_test_add_func ("/option/arg/ignore/long", ignore_test1);
+ g_test_add_func ("/option/arg/ignore/short", ignore_test2);
+ g_test_add_func ("/option/arg/ignore/arg", ignore_test3);
+ g_test_add_func ("/option/context/add", add_test1);
/* Test parsing empty args */
- g_test_add_func ("/context/empty1", empty_test1);
- g_test_add_func ("/context/empty2", empty_test2);
- g_test_add_func ("/context/empty3", empty_test3);
+ /* Note there used to be an empty1 here, but it effectively moved
+ * to option-argv0.c.
+ */
+ g_test_add_func ("/option/context/empty2", empty_test2);
+ g_test_add_func ("/option/context/empty3", empty_test3);
/* Test handling of rest args */
- g_test_add_func ("/arg/rest/non-option", rest_test1);
- g_test_add_func ("/arg/rest/separator1", rest_test2);
- g_test_add_func ("/arg/rest/separator2", rest_test2a);
- g_test_add_func ("/arg/rest/separator3", rest_test2b);
- g_test_add_func ("/arg/rest/separator4", rest_test2c);
- g_test_add_func ("/arg/rest/separator5", rest_test2d);
- g_test_add_func ("/arg/remaining/non-option", rest_test3);
- g_test_add_func ("/arg/remaining/separator", rest_test4);
- g_test_add_func ("/arg/remaining/array", rest_test5);
+ g_test_add_func ("/option/arg/rest/non-option", rest_test1);
+ g_test_add_func ("/option/arg/rest/separator1", rest_test2);
+ g_test_add_func ("/option/arg/rest/separator2", rest_test2a);
+ g_test_add_func ("/option/arg/rest/separator3", rest_test2b);
+ g_test_add_func ("/option/arg/rest/separator4", rest_test2c);
+ g_test_add_func ("/option/arg/rest/separator5", rest_test2d);
+ g_test_add_func ("/option/arg/remaining/non-option", rest_test3);
+ g_test_add_func ("/option/arg/remaining/separator", rest_test4);
+ g_test_add_func ("/option/arg/remaining/array", rest_test5);
+
+ /* Test some invalid flag combinations */
+ g_test_add_func ("/option/arg/reverse-string", flag_reverse_string);
+ g_test_add_func ("/option/arg/optional-int", flag_optional_int);
/* regression tests for individual bugs */
- g_test_add_func ("/bug/unknown-short", unknown_short_test);
- g_test_add_func ("/bug/lonely-dash", lonely_dash_test);
- g_test_add_func ("/bug/missing-arg", missing_arg_test);
+ g_test_add_func ("/option/bug/unknown-short", unknown_short_test);
+ g_test_add_func ("/option/bug/lonely-dash", lonely_dash_test);
+ g_test_add_func ("/option/bug/missing-arg", missing_arg_test);
+ g_test_add_func ("/option/bug/dash-arg", dash_arg_test);
return g_test_run();
}