[glib] Fix /contenttype/guess test
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Fix /contenttype/guess test
- Date: Thu, 28 Jun 2012 13:57:51 +0000 (UTC)
commit d023b81a7a261782f2c88df7751f3476bd802b99
Author: Martin Pitt <martinpitt gnome org>
Date: Wed Jun 27 16:30:38 2012 +0200
Fix /contenttype/guess test
After fixing bug 674452 this test case now reliably fails, as "ABC abc" is text
and definitively not PowerPoint. It previously worked as g_content_type_guess()
was reading beyond the boundary of the data due to specifying -1 as data
length.
Update that test case to expect a PO template instead, and add two more with a
definitive PO template syntax and some binary data. We do not currently have a
MIME magic for PowerPoint, so we cannot actually detect it with certainty, but
at least make sure that the returned MIME type is correct.
https://bugzilla.gnome.org/show_bug.cgi?id=678941
gio/tests/contenttype.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/gio/tests/contenttype.c b/gio/tests/contenttype.c
index 9e0f9af..c44bcc2 100644
--- a/gio/tests/contenttype.c
+++ b/gio/tests/contenttype.c
@@ -55,10 +55,27 @@ test_guess (void)
g_free (res);
g_free (expected);
+ /* this is potentially ambiguous: it does not match the PO template format,
+ * but looks like text so it can't be Powerpoint */
res = g_content_type_guess ("test.pot", (guchar *)"ABC abc", 7, &uncertain);
+ expected = g_content_type_from_mime_type ("text/x-gettext-translation-template");
+ g_assert (g_content_type_equals (expected, res));
+ g_assert (!uncertain);
+ g_free (res);
+ g_free (expected);
+
+ res = g_content_type_guess ("test.pot", (guchar *)"msgid \"", 7, &uncertain);
+ expected = g_content_type_from_mime_type ("text/x-gettext-translation-template");
+ g_assert (g_content_type_equals (expected, res));
+ g_assert (!uncertain);
+ g_free (res);
+ g_free (expected);
+
+ res = g_content_type_guess ("test.pot", (guchar *)"\xCF\xD0\xE0\x11", 4, &uncertain);
expected = g_content_type_from_mime_type ("application/vnd.ms-powerpoint");
g_assert (g_content_type_equals (expected, res));
- g_assert (uncertain);
+ /* we cannot reliably detect binary powerpoint files as long as there is no
+ * defined MIME magic, so do not check uncertain here */
g_free (res);
g_free (expected);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]