From 885bd3da2d33d29f04fe995bd24fb90e1e77d5db Mon Sep 17 00:00:00 2001 From: Arjan Molenaar Date: Fri, 8 Nov 2024 20:25:00 +0100 Subject: [PATCH 1/2] macos: Add extra content type tests --- gio/tests/contenttype.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/gio/tests/contenttype.c b/gio/tests/contenttype.c index c2987123f8..af6e8d26ee 100644 --- a/gio/tests/contenttype.c +++ b/gio/tests/contenttype.c @@ -520,6 +520,36 @@ test_mime_from_content (void) #endif } +static void +test_mime_to_content (void) +{ +#ifdef __APPLE__ + gchar *uti; + uti = g_content_type_from_mime_type ("image/bmp"); + g_assert_cmpstr (uti, ==, "com.microsoft.bmp"); + g_free (uti); + uti = g_content_type_from_mime_type ("image/gif"); + g_assert_cmpstr (uti, ==, "com.compuserve.gif"); + g_free (uti); + uti = g_content_type_from_mime_type ("image/png"); + g_assert_cmpstr (uti, ==, "public.png"); + g_free (uti); + uti = g_content_type_from_mime_type ("text/*"); + g_assert_cmpstr (uti, ==, "public.text"); + g_free (uti); + uti = g_content_type_from_mime_type ("image/svg+xml"); + g_assert_cmpstr (uti, ==, "public.svg-image"); + g_free (uti); + uti = g_content_type_from_mime_type ("application/my-custom-type"); + g_assert (g_str_has_prefix (uti, "dyn.")); + g_free (uti); +#elif defined(G_OS_WIN32) + g_test_skip ("mime from content type test not implemented on WIN32"); +#else + g_test_skip ("mime from content type test not implemented on UNIX"); +#endif +} + int main (int argc, char *argv[]) { @@ -527,6 +557,7 @@ main (int argc, char *argv[]) g_test_add_func ("/contenttype/guess", test_guess); g_test_add_func ("/contenttype/guess_svg_from_data", test_guess_svg_from_data); + g_test_add_func ("/contenttype/mime_to_content", test_mime_to_content); g_test_add_func ("/contenttype/mime_from_content", test_mime_from_content); g_test_add_func ("/contenttype/unknown", test_unknown); g_test_add_func ("/contenttype/subtype", test_subtype); -- GitLab From 7f818a82b4559c1348042e8c0b7d30160ae562a2 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 8 Nov 2024 22:22:16 +0000 Subject: [PATCH 2/2] Apply 1 suggestion(s) to 1 file(s) --- gio/tests/contenttype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gio/tests/contenttype.c b/gio/tests/contenttype.c index af6e8d26ee..9ea75dbaf2 100644 --- a/gio/tests/contenttype.c +++ b/gio/tests/contenttype.c @@ -541,7 +541,7 @@ test_mime_to_content (void) g_assert_cmpstr (uti, ==, "public.svg-image"); g_free (uti); uti = g_content_type_from_mime_type ("application/my-custom-type"); - g_assert (g_str_has_prefix (uti, "dyn.")); + g_assert_true (g_str_has_prefix (uti, "dyn.")); g_free (uti); #elif defined(G_OS_WIN32) g_test_skip ("mime from content type test not implemented on WIN32"); -- GitLab