summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2006-05-11 18:37:15 +0000
committerBastien Nocera <hadess@src.gnome.org>2006-05-11 18:37:15 +0000
commit93ec25ad676b33e0cdf61649156d0b028f6f9aab (patch)
tree7aae344773ad63a9b5c4cb21894256b2eb2c8184 /tests
parent268084caf93aca272da086749afa3a1e58c76a83 (diff)
add documentation for G_OPTION_ARG_INT64
2006-05-11 Bastien Nocera <hadess@hadess.net> * glib/tmpl/option.sgml: add documentation for G_OPTION_ARG_INT64 2006-05-11 Bastien Nocera <hadess@hadess.net> * glib/goption.c: (parse_int64), (parse_arg), (free_changes_list): * glib/goption.h: * tests/option-test.c: (arg_test6), (main): add an int64 type for GOption (G_OPTION_ARG_INT64) (#341237)
Diffstat (limited to 'tests')
-rw-r--r--tests/option-test.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/option-test.c b/tests/option-test.c
index 48dd2531f..65e1f35e5 100644
--- a/tests/option-test.c
+++ b/tests/option-test.c
@@ -12,6 +12,8 @@ gchar *arg_test2_string;
gchar *arg_test3_filename;
gdouble arg_test4_double;
gdouble arg_test5_double;
+gint64 arg_test6_int64;
+gint64 arg_test6_int64_2;
gchar *callback_test1_string;
int callback_test2_int;
@@ -407,6 +409,36 @@ arg_test5 (void)
g_option_context_free (context);
}
+void
+arg_test6 (void)
+{
+ GOptionContext *context;
+ gboolean retval;
+ GError *error = NULL;
+ gchar **argv;
+ int argc;
+ GOptionEntry entries [] =
+ { { "test", 0, 0, G_OPTION_ARG_INT64, &arg_test6_int64, NULL, NULL },
+ { "test2", 0, 0, G_OPTION_ARG_INT64, &arg_test6_int64_2, 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 4294967297 --test 4294967296 --test2 0xfffffffff", &argc);
+
+ retval = g_option_context_parse (context, &argc, &argv, &error);
+ g_assert (retval);
+
+ /* Last arg specified is the one that should be stored */
+ g_assert (arg_test6_int64 == 4294967296LL);
+ g_assert (arg_test6_int64_2 == 0xfffffffffLL);
+
+ g_strfreev (argv);
+ g_option_context_free (context);
+}
+
static gboolean
callback_parse1 (const gchar *option_name, const gchar *value,
gpointer data, GError **error)
@@ -1370,6 +1402,7 @@ main (int argc, char **argv)
arg_test3 ();
arg_test4 ();
arg_test5 ();
+ arg_test6 ();
/* Test string arrays */
array_test1 ();