2 * Copyright (C) 2003,2004 Red Hat, Inc.
3 * Copyright (C) 2003,2004 Jonathan Blandford <jrb@alum.mit.edu>
5 * Licensed under the Academic Free License version 2.0
6 * Or under the following terms:
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #include "xdgmimeglob.h"
30 test_individual_glob (const char *glob,
31 XdgGlobType expected_type)
33 XdgGlobType test_type;
35 test_type = _xdg_glob_determine_type (glob);
36 if (test_type != expected_type)
38 printf ("Test Failed: %s is of type %s, but %s is expected\n",
40 ((test_type == XDG_GLOB_LITERAL)?"XDG_GLOB_LITERAL":
41 ((test_type == XDG_GLOB_SIMPLE)?"XDG_GLOB_SIMPLE":"XDG_GLOB_FULL")),
42 ((expected_type == XDG_GLOB_LITERAL)?"XDG_GLOB_LITERAL":
43 ((expected_type == XDG_GLOB_SIMPLE)?"XDG_GLOB_SIMPLE":"XDG_GLOB_COMPLEX")));
50 test_individual_glob ("*.gif", XDG_GLOB_SIMPLE);
51 test_individual_glob ("Foo*.gif", XDG_GLOB_FULL);
52 test_individual_glob ("*[4].gif", XDG_GLOB_FULL);
53 test_individual_glob ("Makefile", XDG_GLOB_LITERAL);
54 test_individual_glob ("sldkfjvlsdf\\\\slkdjf", XDG_GLOB_FULL);
55 test_individual_glob ("tree.[ch]", XDG_GLOB_FULL);
59 test_alias (const char *mime_a,
65 actual = xdg_mime_mime_type_equal (mime_a, mime_b);
67 if (actual != expected)
69 printf ("Test Failed: %s is %s to %s\n",
70 mime_a, actual ? "equal" : "not equal", mime_b);
77 test_alias ("application/wordperfect", "application/vnd.wordperfect", 1);
78 test_alias ("application/x-gnome-app-info", "application/x-desktop", 1);
79 test_alias ("application/x-wordperfect", "application/vnd.wordperfect", 1);
80 test_alias ("application/x-wordperfect", "audio/x-midi", 0);
81 test_alias ("/", "vnd/vnd", 0);
82 test_alias ("application/octet-stream", "text/plain", 0);
83 test_alias ("text/plain", "text/*", 0);
87 test_subclass (const char *mime_a,
93 actual = xdg_mime_mime_type_subclass (mime_a, mime_b);
95 if (actual != expected)
97 printf ("Test Failed: %s is %s of %s\n",
98 mime_a, actual ? "subclass" : "not subclass", mime_b);
103 test_subclassing (void)
105 test_subclass ("application/rtf", "text/plain", 1);
106 test_subclass ("message/news", "text/plain", 1);
107 test_subclass ("message/news", "message/*", 1);
108 test_subclass ("message/news", "text/*", 1);
109 test_subclass ("message/news", "application/octet-stream", 1);
110 test_subclass ("application/rtf", "application/octet-stream", 1);
111 test_subclass ("application/x-gnome-app-info", "text/plain", 1);
112 test_subclass ("image/x-djvu", "image/vnd.djvu", 1);
113 test_subclass ("image/vnd.djvu", "image/x-djvu", 1);
114 test_subclass ("image/vnd.djvu", "text/plain", 0);
115 test_subclass ("image/vnd.djvu", "text/*", 0);
116 test_subclass ("text/*", "text/plain", 0);
120 main (int argc, char *argv[])
123 const char *file_name;
130 for (i = 1; i < argc; i++)
133 result = xdg_mime_get_mime_type_for_file (file_name, NULL);
134 printf ("File \"%s\" has a mime-type of %s\n", file_name, result);