From 1e90d9cd74b1f3cc256bcd4491a67c97f6c264f0 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Fri, 28 May 2021 17:15:53 +0200 Subject: [PATCH] Add test case for g_prefix_error_literal() function --- glib/tests/error.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/glib/tests/error.c b/glib/tests/error.c index 48f480222..51a0c35dc 100644 --- a/glib/tests/error.c +++ b/glib/tests/error.c @@ -69,6 +69,27 @@ test_prefix (void) g_propagate_prefixed_error (NULL, src, "foo %d %s: ", 1, "two"); } +static void +test_prefix_literal (void) +{ + GError *error = NULL; + + g_prefix_error_literal (NULL, "foo: "); + + g_prefix_error_literal (&error, "foo: "); + g_assert_null (error); + + error = NULL; + g_prefix_error_literal (&error, "foo: "); + g_assert_null (error); + + error = g_error_new_literal (G_MARKUP_ERROR, G_MARKUP_ERROR_EMPTY, "bla"); + g_assert_nonnull (error); + g_prefix_error_literal (&error, "foo: "); + g_assert_cmpstr (error->message, ==, "foo: bla"); + g_error_free (error); +} + static void test_literal (void) { @@ -374,6 +395,7 @@ main (int argc, char *argv[]) g_test_add_func ("/error/overwrite", test_overwrite); g_test_add_func ("/error/prefix", test_prefix); + g_test_add_func ("/error/prefix-literal", test_prefix_literal); g_test_add_func ("/error/literal", test_literal); g_test_add_func ("/error/copy", test_copy); g_test_add_func ("/error/matches", test_matches);