Use g_assert_no_error

The option-context test had its own version.
This commit is contained in:
Matthias Clasen 2011-02-12 21:08:57 -05:00
parent cf3ad6e293
commit 147139d968

View File

@ -414,16 +414,6 @@ error_test3 (void)
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)
{
@ -443,7 +433,7 @@ 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_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
@ -472,7 +462,7 @@ arg_test2 (void)
argv = split_string ("program --test foo --test bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
@ -503,7 +493,7 @@ arg_test3 (void)
argv = split_string ("program --test foo.txt", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
@ -535,7 +525,7 @@ arg_test4 (void)
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_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
@ -576,7 +566,7 @@ arg_test5 (void)
}
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
@ -610,7 +600,7 @@ arg_test6 (void)
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_no_error (error);
g_assert (retval);
/* Last arg specified is the one that should be stored */
@ -648,7 +638,7 @@ callback_test1 (void)
argv = split_string ("program --test foo.txt", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
g_assert (strcmp (callback_test1_string, "foo.txt") == 0);
@ -686,7 +676,7 @@ callback_test2 (void)
argv = split_string ("program --test --test", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test2_int == 2);
@ -727,7 +717,7 @@ callback_test_optional_1 (void)
argv = split_string ("program --test foo.txt", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
g_assert (strcmp (callback_test_optional_string, "foo.txt") == 0);
@ -760,7 +750,7 @@ callback_test_optional_2 (void)
argv = split_string ("program --test", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
@ -793,7 +783,7 @@ callback_test_optional_3 (void)
argv = split_string ("program -t foo.txt", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
g_assert (strcmp (callback_test_optional_string, "foo.txt") == 0);
@ -827,7 +817,7 @@ callback_test_optional_4 (void)
argv = split_string ("program -t", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
@ -862,7 +852,7 @@ callback_test_optional_5 (void)
argv = split_string ("program --test --dummy", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
@ -897,7 +887,7 @@ callback_test_optional_6 (void)
argv = split_string ("program -t -d", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
@ -932,7 +922,7 @@ callback_test_optional_7 (void)
argv = split_string ("program -td", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string == NULL);
@ -967,7 +957,7 @@ callback_test_optional_8 (void)
argv = split_string ("program -dt foo.txt", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
g_assert (callback_test_optional_string);
@ -1009,7 +999,7 @@ callback_remaining_test1 (void)
argv = split_string ("program foo.txt blah.txt", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
g_assert (callback_remaining_args->len == 2);
@ -1121,7 +1111,7 @@ ignore_test1 (void)
argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1155,7 +1145,7 @@ ignore_test2 (void)
argv = split_string ("program -test", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1189,7 +1179,7 @@ ignore_test3 (void)
argv_copy = copy_stringv (argv, argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1224,7 +1214,7 @@ array_test1 (void)
argv = split_string ("program --test foo --test bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1326,7 +1316,7 @@ rest_test1 (void)
argv = split_string ("program foo --test bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1361,7 +1351,7 @@ rest_test2 (void)
argv = split_string ("program foo --test -- -bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1397,7 +1387,7 @@ rest_test2a (void)
argv = split_string ("program foo --test -- bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1432,7 +1422,7 @@ rest_test2b (void)
argv = split_string ("program foo --test -bar --", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1466,7 +1456,7 @@ rest_test2c (void)
argv = split_string ("program --test foo -- bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1500,7 +1490,7 @@ rest_test2d (void)
argv = split_string ("program --test -- -bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1537,7 +1527,7 @@ rest_test3 (void)
argv = split_string ("program foo --test bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1575,7 +1565,7 @@ rest_test4 (void)
argv = split_string ("program foo --test -- -bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1612,7 +1602,7 @@ rest_test5 (void)
argv = split_string ("program foo --test bar", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
/* Check array */
@ -1669,7 +1659,7 @@ void lonely_dash_test (void)
argv = split_string ("program -", &argc);
retval = g_option_context_parse (context, &argc, &argv, &error);
assert_no_error (error);
g_assert_no_error (error);
g_assert (retval);
g_assert (argv[1] && strcmp (argv[1], "-") == 0);