6 GError
*error
, *dest
, *src
;
8 if (!g_test_undefined ())
11 error
= g_error_new_literal (G_MARKUP_ERROR
, G_MARKUP_ERROR_EMPTY
, "bla");
13 g_test_expect_message (G_LOG_DOMAIN
, G_LOG_LEVEL_WARNING
,
14 "*set over the top*");
15 g_set_error_literal (&error
, G_MARKUP_ERROR
, G_MARKUP_ERROR_PARSE
, "bla");
16 g_test_assert_expected_messages ();
18 g_assert_error (error
, G_MARKUP_ERROR
, G_MARKUP_ERROR_EMPTY
);
22 dest
= g_error_new_literal (G_MARKUP_ERROR
, G_MARKUP_ERROR_EMPTY
, "bla");
23 src
= g_error_new_literal (G_MARKUP_ERROR
, G_MARKUP_ERROR_PARSE
, "bla");
25 g_test_expect_message (G_LOG_DOMAIN
, G_LOG_LEVEL_WARNING
,
26 "*set over the top*");
27 g_propagate_error (&dest
, src
);
28 g_test_assert_expected_messages ();
30 g_assert_error (dest
, G_MARKUP_ERROR
, G_MARKUP_ERROR_EMPTY
);
41 g_prefix_error (&error
, "foo %d %s: ", 1, "two");
42 g_assert (error
== NULL
);
44 error
= g_error_new_literal (G_MARKUP_ERROR
, G_MARKUP_ERROR_EMPTY
, "bla");
45 g_prefix_error (&error
, "foo %d %s: ", 1, "two");
46 g_assert_cmpstr (error
->message
, ==, "foo 1 two: bla");
50 src
= g_error_new_literal (G_MARKUP_ERROR
, G_MARKUP_ERROR_EMPTY
, "bla");
51 g_propagate_prefixed_error (&dest
, src
, "foo %d %s: ", 1, "two");
52 g_assert_cmpstr (dest
->message
, ==, "foo 1 two: bla");
62 g_set_error_literal (&error
, G_MARKUP_ERROR
, G_MARKUP_ERROR_EMPTY
, "%s %d %x");
63 g_assert_error (error
, G_MARKUP_ERROR
, G_MARKUP_ERROR_EMPTY
);
64 g_assert_cmpstr (error
->message
, ==, "%s %d %x");
75 g_set_error_literal (&error
, G_MARKUP_ERROR
, G_MARKUP_ERROR_EMPTY
, "%s %d %x");
76 copy
= g_error_copy (error
);
78 g_assert_error (copy
, G_MARKUP_ERROR
, G_MARKUP_ERROR_EMPTY
);
79 g_assert_cmpstr (copy
->message
, ==, "%s %d %x");
86 main (int argc
, char *argv
[])
88 g_test_init (&argc
, &argv
, NULL
);
90 g_test_add_func ("/error/overwrite", test_overwrite
);
91 g_test_add_func ("/error/prefix", test_prefix
);
92 g_test_add_func ("/error/literal", test_literal
);
93 g_test_add_func ("/error/copy", test_copy
);