nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #include <glib.h> |
2 | |||
3 | static void |
||
4 | test_overwrite (void) |
||
5 | { |
||
6 | GError *error, *dest, *src; |
||
7 | |||
8 | if (!g_test_undefined ()) |
||
9 | return; |
||
10 | |||
11 | error = g_error_new_literal (G_MARKUP_ERROR, G_MARKUP_ERROR_EMPTY, "bla"); |
||
12 | |||
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 (); |
||
17 | |||
18 | g_assert_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_EMPTY); |
||
19 | g_error_free (error); |
||
20 | |||
21 | |||
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"); |
||
24 | |||
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 (); |
||
29 | |||
30 | g_assert_error (dest, G_MARKUP_ERROR, G_MARKUP_ERROR_EMPTY); |
||
31 | g_error_free (dest); |
||
32 | } |
||
33 | |||
34 | static void |
||
35 | test_prefix (void) |
||
36 | { |
||
37 | GError *error; |
||
38 | GError *dest, *src; |
||
39 | |||
40 | error = NULL; |
||
41 | g_prefix_error (&error, "foo %d %s: ", 1, "two"); |
||
42 | g_assert (error == NULL); |
||
43 | |||
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"); |
||
47 | g_error_free (error); |
||
48 | |||
49 | dest = NULL; |
||
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"); |
||
53 | g_error_free (dest); |
||
54 | } |
||
55 | |||
56 | static void |
||
57 | test_literal (void) |
||
58 | { |
||
59 | GError *error; |
||
60 | |||
61 | error = NULL; |
||
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"); |
||
65 | g_error_free (error); |
||
66 | } |
||
67 | |||
68 | static void |
||
69 | test_copy (void) |
||
70 | { |
||
71 | GError *error; |
||
72 | GError *copy; |
||
73 | |||
74 | error = NULL; |
||
75 | g_set_error_literal (&error, G_MARKUP_ERROR, G_MARKUP_ERROR_EMPTY, "%s %d %x"); |
||
76 | copy = g_error_copy (error); |
||
77 | |||
78 | g_assert_error (copy, G_MARKUP_ERROR, G_MARKUP_ERROR_EMPTY); |
||
79 | g_assert_cmpstr (copy->message, ==, "%s %d %x"); |
||
80 | |||
81 | g_error_free (error); |
||
82 | g_error_free (copy); |
||
83 | } |
||
84 | |||
85 | int |
||
86 | main (int argc, char *argv[]) |
||
87 | { |
||
88 | g_test_init (&argc, &argv, NULL); |
||
89 | |||
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); |
||
94 | |||
95 | return g_test_run (); |
||
96 | } |
||
97 |