10 res = g_content_type_guess ("/etc/", NULL, 0, &uncertain);
11 expected = g_content_type_from_mime_type ("inode/directory");
12 g_assert (g_content_type_equals (expected, res));
16 res = g_content_type_guess ("foo.txt", NULL, 0, &uncertain);
17 expected = g_content_type_from_mime_type ("text/plain");
18 g_assert (g_content_type_equals (expected, res));
29 unknown = g_content_type_from_mime_type ("application/octet-stream");
30 g_assert (g_content_type_is_unknown (unknown));
31 str = g_content_type_get_mime_type (unknown);
32 g_assert_cmpstr (str, ==, "application/octet-stream");
43 plain = g_content_type_from_mime_type ("text/plain");
44 xml = g_content_type_from_mime_type ("application/xml");
46 g_assert (g_content_type_is_a (xml, plain));
53 find_mime (gconstpointer a, gconstpointer b)
55 if (g_content_type_equals (a, b))
67 plain = g_content_type_from_mime_type ("text/plain");
68 xml = g_content_type_from_mime_type ("application/xml");
70 types = g_content_types_get_registered ();
72 g_assert (g_list_length (types) > 1);
74 /* just check that some types are in the list */
75 g_assert (g_list_find_custom (types, plain, find_mime) != NULL);
76 g_assert (g_list_find_custom (types, xml, find_mime) != NULL);
78 g_list_free_full (types, g_free);
85 test_executable (void)
89 type = g_content_type_from_mime_type ("application/x-executable");
90 g_assert (g_content_type_can_be_executable (type));
93 type = g_content_type_from_mime_type ("text/plain");
94 g_assert (g_content_type_can_be_executable (type));
97 type = g_content_type_from_mime_type ("image/png");
98 g_assert (!g_content_type_can_be_executable (type));
103 test_description (void)
108 type = g_content_type_from_mime_type ("text/plain");
109 desc = g_content_type_get_description (type);
110 g_assert (desc != NULL);
117 main (int argc, char *argv[])
121 g_test_init (&argc, &argv, NULL);
123 g_test_add_func ("/contenttype/guess", test_guess);
124 g_test_add_func ("/contenttype/unknown", test_unknown);
125 g_test_add_func ("/contenttype/subtype", test_subtype);
126 g_test_add_func ("/contenttype/list", test_list);
127 g_test_add_func ("/contenttype/executable", test_executable);
128 g_test_add_func ("/contenttype/description", test_description);
130 return g_test_run ();