summaryrefslogtreecommitdiff
path: root/gtk/xdgmime/test-mime.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2004-11-08 19:36:12 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-11-08 19:36:12 +0000
commitd0e90e40b1645ed93bf1dfca4f45693489c813e9 (patch)
tree4d04617969321524b69add824dc8d01f979d9ee1 /gtk/xdgmime/test-mime.c
parent9b86c72c96c97c0904615c0822c0ea6a47a9be7d (diff)
downloadgdk-pixbuf-d0e90e40b1645ed93bf1dfca4f45693489c813e9.tar.gz
Sync from upstream
2004-11-08 Matthias Clasen <mclasen@redhat.com> * Sync from upstream
Diffstat (limited to 'gtk/xdgmime/test-mime.c')
-rw-r--r--gtk/xdgmime/test-mime.c95
1 files changed, 67 insertions, 28 deletions
diff --git a/gtk/xdgmime/test-mime.c b/gtk/xdgmime/test-mime.c
index 7a669c9b1..b0bcc875f 100644
--- a/gtk/xdgmime/test-mime.c
+++ b/gtk/xdgmime/test-mime.c
@@ -1,31 +1,3 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
-/* test-mime.c: Test program for mime type identification
- *
- * More info can be found at http://www.freedesktop.org/standards/
- *
- * Copyright (C) 2003 Red Hat, Inc.
- * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
- *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
#include "xdgmime.h"
#include "xdgmimeglob.h"
#include <string.h>
@@ -61,6 +33,67 @@ test_glob_type (void)
test_individual_glob ("tree.[ch]", XDG_GLOB_FULL);
}
+static void
+test_alias (const char *mime_a,
+ const char *mime_b,
+ int expected)
+{
+ int actual;
+
+ actual = xdg_mime_mime_type_equal (mime_a, mime_b);
+
+ if (actual != expected)
+ {
+ printf ("Test Failed: %s is %s to %s\n",
+ mime_a, actual ? "equal" : "not equal", mime_b);
+ }
+}
+
+static void
+test_aliasing (void)
+{
+ test_alias ("application/wordperfect", "application/vnd.wordperfect", 1);
+ test_alias ("application/x-gnome-app-info", "application/x-desktop", 1);
+ test_alias ("application/x-wordperfect", "application/vnd.wordperfect", 1);
+ test_alias ("application/x-wordperfect", "audio/x-midi", 0);
+ test_alias ("/", "vnd/vnd", 0);
+ test_alias ("application/octet-stream", "text/plain", 0);
+ test_alias ("text/plain", "text/*", 0);
+}
+
+static void
+test_subclass (const char *mime_a,
+ const char *mime_b,
+ int expected)
+{
+ int actual;
+
+ actual = xdg_mime_mime_type_subclass (mime_a, mime_b);
+
+ if (actual != expected)
+ {
+ printf ("Test Failed: %s is %s of %s\n",
+ mime_a, actual ? "subclass" : "not subclass", mime_b);
+ }
+}
+
+static void
+test_subclassing (void)
+{
+ test_subclass ("application/rtf", "text/plain", 1);
+ test_subclass ("message/news", "text/plain", 1);
+ test_subclass ("message/news", "message/*", 1);
+ test_subclass ("message/news", "text/*", 1);
+ test_subclass ("message/news", "application/octet-stream", 1);
+ test_subclass ("application/rtf", "application/octet-stream", 1);
+ test_subclass ("application/x-gnome-app-info", "text/plain", 1);
+ test_subclass ("image/x-djvu", "image/vnd.djvu", 1);
+ test_subclass ("image/vnd.djvu", "image/x-djvu", 1);
+ test_subclass ("image/vnd.djvu", "text/plain", 0);
+ test_subclass ("image/vnd.djvu", "text/*", 0);
+ test_subclass ("text/*", "text/plain", 0);
+}
+
int
main (int argc, char *argv[])
{
@@ -69,6 +102,9 @@ main (int argc, char *argv[])
int i;
test_glob_type ();
+ test_aliasing ();
+ test_subclassing ();
+
for (i = 1; i < argc; i++)
{
file_name = argv[i];
@@ -76,6 +112,9 @@ main (int argc, char *argv[])
printf ("File \"%s\" has a mime-type of %s\n", file_name, result);
}
+#if 0
+ xdg_mime_dump ();
+#endif
return 0;
}