Set prgname to <unknown> if argc and argv are NULL.

2004-08-30  Anders Carlsson  <andersca@gnome.org>

	* glib/goption.c: (g_option_context_parse):
	Set prgname to <unknown> if argc and argv are NULL.

	* tests/option-test.c: (empty_test1), (main):
	Add test case for that.
This commit is contained in:
Anders Carlsson
2004-08-30 20:40:52 +00:00
committed by Anders Carlsson
parent fd92ac8f52
commit 11957cabec
7 changed files with 66 additions and 2 deletions

View File

@@ -410,6 +410,24 @@ add_test1 (void)
g_option_context_free (context);
}
void
empty_test1 (void)
{
GOptionContext *context;
GOptionEntry entries [] =
{ { NULL } };
context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_parse (context, NULL, NULL, NULL);
g_assert (strcmp (g_get_prgname (), "<unknown>") == 0);
g_option_context_free (context);
}
int
main (int argc, char **argv)
{
@@ -433,6 +451,9 @@ main (int argc, char **argv)
ignore_test2 ();
add_test1 ();
/* Test parsing empty args */
empty_test1 ();
return 0;
}