[glib] Add a test for the previous fix



commit 2dc11a55f8a4f522d14e9efc7698f3a05f4c2f06
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Sep 12 22:28:35 2016 -0400

    Add a test for the previous fix

 glib/tests/option-context.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/glib/tests/option-context.c b/glib/tests/option-context.c
index 12b8622..a1e7b05 100644
--- a/glib/tests/option-context.c
+++ b/glib/tests/option-context.c
@@ -2478,6 +2478,38 @@ short_remaining (void)
   g_option_context_free (context);
 }
 
+static void
+double_free (void)
+{
+  gchar* text = NULL;
+  GOptionEntry entries[] =
+  {
+    { "known", 0, 0, G_OPTION_ARG_STRING, &text, NULL, NULL },
+    { NULL }
+  };
+  GOptionContext* context;
+  gchar **argv;
+  gint argc;
+  GError *error = NULL;
+
+  g_test_bug ("646926");
+
+  argv = split_string ("program --known=foo --known=bar --unknown=baz", &argc);
+
+  context = g_option_context_new (NULL);
+
+  g_option_context_add_main_entries (context, entries, NULL);
+  g_option_context_set_ignore_unknown_options (context, FALSE);
+  g_option_context_parse (context, &argc, &argv, &error);
+
+  g_assert_error (error, G_OPTION_ERROR, G_OPTION_ERROR_UNKNOWN_OPTION);
+  g_assert_null (text);
+
+  g_option_context_free (context);
+  g_clear_error (&error);
+
+}
+
 int
 main (int   argc,
       char *argv[])
@@ -2589,7 +2621,8 @@ main (int   argc,
   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);
-  g_test_add_func ("/option/bug/short-remaining", short_remaining); 
+  g_test_add_func ("/option/bug/short-remaining", short_remaining);
+  g_test_add_func ("/option/bug/double-free", double_free);
 
   return g_test_run();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]