#include <stdio.h>
#include <string.h>
#include <locale.h>
+#include <math.h>
+
static GOptionEntry main_entries[] = {
{ "main-switch", 0, 0,
g_option_context_free (context);
}
-
static void
arg_test4 (void)
{
}
+static void
+double_zero (void)
+{
+ GOptionContext *context;
+ gboolean retval;
+ GError *error = NULL;
+ gchar **argv_copy;
+ gchar **argv;
+ int argc;
+ double test_val = NAN;
+ GOptionEntry entries [] =
+ { { "test", 0, 0, G_OPTION_ARG_DOUBLE, &test_val, NULL, NULL },
+ { NULL } };
+
+ context = g_option_context_new (NULL);
+ g_option_context_add_main_entries (context, entries, NULL);
+
+ /* Now try parsing */
+ argv = split_string ("program --test 0", &argc);
+ argv_copy = copy_stringv (argv, argc);
+
+ retval = g_option_context_parse (context, &argc, &argv, &error);
+ g_assert_no_error (error);
+ g_assert (retval);
+
+ /* Last arg specified is the one that should be stored */
+ g_assert (test_val == 0);
+
+ g_strfreev (argv_copy);
+ g_free (argv);
+ g_option_context_free (context);
+}
+
int
main (int argc,
char *argv[])
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/double-free", double_free);
+ g_test_add_func ("/option/bug/double-zero", double_zero);
return g_test_run();
}