+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <locale.h>
g_option_context_free (context);
}
+static void
+assert_no_error (GError *error)
+{
+ if (error)
+ {
+ fprintf (stderr, "unexpected error: %s, %d, %s\n", g_quark_to_string (error->domain), error->code, error->message);
+ exit (1);
+ }
+}
+
void
arg_test1 (void)
{
argv = split_string ("program --test 20 --test 30", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
argv = split_string ("program --test foo --test bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
argv = split_string ("program --test foo.txt", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
argv = split_string ("program --test 20.0 --test 30.03", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
}
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
argv = split_string ("program --test 4294967297 --test 4294967296 --test2 0xfffffffff", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
argv = split_string ("program --test foo.txt", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
g_assert (strcmp (callback_test1_string, "foo.txt") == 0);
argv = split_string ("program --test --test", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
g_assert (callback_test2_int == 2);
argv = split_string ("program --test foo.txt", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
g_assert (strcmp (callback_test_optional_string, "foo.txt") == 0);
argv = split_string ("program --test", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
argv = split_string ("program -t foo.txt", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
g_assert (strcmp (callback_test_optional_string, "foo.txt") == 0);
argv = split_string ("program -t", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
argv = split_string ("program --test --dummy", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
argv = split_string ("program -t -d", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
argv = split_string ("program -td", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
argv = split_string ("program -dt foo.txt", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string);
argv = split_string ("program foo.txt blah.txt", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
g_assert (callback_remaining_args->len == 2);
argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv = split_string ("program -test", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv = split_string ("program --test foo --test bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv = split_string ("program foo --test bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv = split_string ("program foo --test -- -bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv = split_string ("program foo --test -- bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv = split_string ("program foo --test -bar --", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv = split_string ("program --test foo -- bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv = split_string ("program --test -- -bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv = split_string ("program foo --test bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv = split_string ("program foo --test -- -bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv = split_string ("program foo --test bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
+ assert_no_error (error);
g_assert (retval);
/* Check array */
argv = split_string ("program -", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
-
+ assert_no_error (error);
g_assert (retval);
g_assert (argv[1] && strcmp (argv[1], "-") == 0);