[gmime] Added unit test for GMimeFilterWindows
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime] Added unit test for GMimeFilterWindows
- Date: Wed, 20 Dec 2017 17:12:39 +0000 (UTC)
commit 7afed8e7140ddb8826b4b8576d50c542ec311154
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date: Sun Dec 17 10:05:09 2017 -0500
Added unit test for GMimeFilterWindows
tests/data/filters/french-fable.cp1252.txt | 18 ++++++++++++
tests/test-filters.c | 42 ++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/tests/data/filters/french-fable.cp1252.txt b/tests/data/filters/french-fable.cp1252.txt
new file mode 100644
index 0000000..6af04b6
--- /dev/null
+++ b/tests/data/filters/french-fable.cp1252.txt
@@ -0,0 +1,18 @@
+Ma�tre Corbeau, sur un arbre perch�,
+Tenait en son bec un fromage.
+Ma�tre Renard, par l�odeur all�ch�,
+Lui tint � peu pr�s ce langage :
+� H� ! bonjour, Monsieur du Corbeau.
+Que vous �tes joli ! Que vous me semblez beau !
+Sans mentir, si votre ramage
+Se rapporte � votre plumage,
+Vous �tes le Ph�nix des h�tes de ces bois. �
+A ces mots le Corbeau ne se sent pas de joie ;
+Et pour montrer sa belle voix,
+Il ouvre un large bec, laisse tomber sa proie.
+Le Renard s�en saisit, et dit : � Mon bon Monsieur,
+Apprenez que tout flatteur
+Vit aux d�pens de celui qui l��coute :
+Cette le�on vaut bien un fromage, sans doute. �
+Le Corbeau, honteux et confus,
+Jura, mais un peu tard, qu�on ne l�y prendrait plus.
diff --git a/tests/test-filters.c b/tests/test-filters.c
index d9c9ff1..0144a6f 100644
--- a/tests/test-filters.c
+++ b/tests/test-filters.c
@@ -365,6 +365,46 @@ error:
g_byte_array_free (actual, TRUE);
}
+static void
+test_windows (const char *datadir, const char *filename, const char *claimed, const char *expected)
+{
+ const char *what = "GMimeFilterWindows";
+ GMimeStream *stream;
+ GMimeFilter *filter;
+ const char *actual;
+ char *path;
+
+ testsuite_check ("%s", what);
+
+ filter = g_mime_filter_windows_new (claimed);
+
+ stream = g_mime_stream_null_new ();
+ path = g_build_filename (datadir, filename, NULL);
+ pump_data_through_filter (filter, path, stream, TRUE, TRUE);
+ g_object_unref (stream);
+ g_free (path);
+
+ actual = g_mime_filter_windows_real_charset ((GMimeFilterWindows *) filter);
+
+ if (strcmp (expected, actual) != 0) {
+ testsuite_check_failed ("%s failed: charsets do not match: expected=%s; actual=%s",
+ what, expected, actual);
+ goto error;
+ }
+
+ if (!g_mime_filter_windows_is_windows_charset ((GMimeFilterWindows *) filter)) {
+ testsuite_check_failed ("%s failed: is_windows_charset returned FALSE", what);
+ goto error;
+ }
+
+ testsuite_check_passed ();
+
+error:
+
+ g_mime_filter_reset (filter);
+ g_object_unref (filter);
+}
+
int main (int argc, char **argv)
{
const char *datadir = "data/filters";
@@ -408,6 +448,8 @@ int main (int argc, char **argv)
test_smtp_data (datadir, "smtp-input.txt", "smtp-output.txt");
+ test_windows (datadir, "french-fable.cp1252.txt", "iso-8859-1", "windows-cp1252");
+
testsuite_end ();
g_mime_shutdown ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]