Add a testcase.

2005-05-06  Matthias Clasen  <mclasen@redhat.com>

	* tests/option-test.c: Add a testcase.

	* glib/goption.c (g_option_context_parse): Treat '-'
	on its own as a non-option argument.  (#168008, Tim Musson,
	Thomas Leonard and others)
This commit is contained in:
Matthias Clasen
2005-05-06 20:10:52 +00:00
committed by Matthias Clasen
parent 2ae1a46b4c
commit 6e60dd8489
6 changed files with 60 additions and 1 deletions

View File

@@ -859,6 +859,30 @@ unknown_short_test (void)
g_option_context_free (context);
}
/* test that lone dashes are treated as non-options */
void lonely_dash_test (void)
{
GOptionContext *context;
gboolean retval;
GError *error = NULL;
gchar **argv;
int argc;
context = g_option_context_new (NULL);
/* Now try parsing */
argv = split_string ("program -", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
g_assert (retval);
g_assert (argv[1] && strcmp (argv[1], "-") == 0);
g_strfreev (argv);
g_option_context_free (context);
}
int
main (int argc, char **argv)
{
@@ -904,5 +928,8 @@ main (int argc, char **argv)
/* test for bug 166609 */
unknown_short_test ();
/* test for bug 168008 */
lonely_dash_test ();
return 0;
}