mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 15:33:39 +02:00
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)
This commit is contained in:
committed by
Bastien Nocera
parent
268084caf9
commit
93ec25ad67
@@ -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 ();
|
||||
|
Reference in New Issue
Block a user