diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-10-30 19:26:56 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-10-30 19:26:56 -0400 |
commit | 2b38d14bf5662f17edd6c38b2ce04335326eeb05 (patch) | |
tree | 77a1e8f4856e1df1fb13d4dd124c1fc49e06498d /testsuite | |
parent | d35a21873e0e4fc37ea877857eb99c1af96b6923 (diff) | |
download | gtk+-2b38d14bf5662f17edd6c38b2ce04335326eeb05.tar.gz |
tests: Improve coverage for css data url parsing
Cover the error conditions as well.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/css/data.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/testsuite/css/data.c b/testsuite/css/data.c index 72533fcfb2..978be0e55e 100644 --- a/testsuite/css/data.c +++ b/testsuite/css/data.c @@ -58,6 +58,15 @@ Test tests[] = { { "charset_base64", "data:text/plain;charset=ISO-8859-5;base64,wOPh29DdILjW0ePb0OLe0g==", "text/plain", CONTENTS("Руслан Ижбулатов") }, + { "wrong_scheme", + "duda:,Hello", + NULL, NULL, 0 }, + { "missing_comma", + "data:text/plain;charset=ISO-8859-1:bla", + NULL, NULL, 0 }, + { "bad_escape", + "data:,abc%00", + NULL, NULL, -1 }, }; static void @@ -70,17 +79,25 @@ test_parse (gconstpointer data) bytes = gtk_css_data_url_parse (test->url, &mimetype, &error); - g_assert (bytes != NULL); - g_assert_no_error (error); - if (test->mimetype == NULL) - g_assert (mimetype == NULL); - else - g_assert_cmpstr (mimetype, ==, test->mimetype); - - g_assert_cmpmem (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), - test->contents, test->contents_len); + if (test->contents) + { + g_assert_nonnull (bytes); + g_assert_no_error (error); + if (test->mimetype == NULL) + g_assert (mimetype == NULL); + else + g_assert_cmpstr (mimetype, ==, test->mimetype); - g_bytes_unref (bytes); + g_assert_cmpmem (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), + test->contents, test->contents_len); + g_bytes_unref (bytes); + } + else + { + g_assert_null (bytes); + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_FILENAME); + g_error_free (error); + } } int |