1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Authors: Jeffrey Stedfast <fejj@novell.com>
5 * Copyright 2005 Novell, Inc. (www.novell.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
32 #include <camel/camel-object.h>
33 #include <camel/camel-mime-utils.h>
35 #include "camel-test.h"
42 /* the first half are rfc compliant cases (which are the most important) */
43 { "=?iso-8859-1?q?this=20is=20some=20text?=", "this is some text", 0 },
44 { "this =?iso-8859-1?q?is_some?= text", "this is some text", 0 },
45 { "=?iso-8859-1?q?th?= =?iso-8859-1?q?is?= is some text", "this is some text", 0 },
46 { "=?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=",
47 "If you can read this you understand the example.", 0 },
49 /* And oddly enough, camel fails on these, removed for now */
51 /* second half: brokenly encoded rfc2047 words */
52 { "foo=?UTF-8?Q?bar?=baz", "foobarbaz", 0 },
53 { "foo =?UTF-8?Q?bar?=baz", "foo barbaz", 0 },
54 { "foo=?UTF-8?Q?bar?= baz", "foobar baz", 0 },
55 { "=?UTF-8?Q?foo bar?=baz", "foo barbaz", 0 },
56 { "foo=?UTF-8?Q?bar baz?=", "foobar baz", 0 },
57 { "=?UTF-8?Q?foo?==?UTF-8?Q?bar baz?=", "foobar baz", 0 },
58 { "=?UTF-8?Q?foo?= =?UTF-8?Q?bar baz?=", "foobar baz", 0 },
59 { "=?UTF-8?Q?foo?= bar =?UTF-8?Q?baz?=", "foo bar baz", 0 },
60 { "=?foo=?UTF-8?Q?bar baz?=", "=?foobar baz", 0 },
61 { "=?foo?=?UTF-8?Q?bar baz?=", "=?foo?bar baz", 0 },
62 { "=?foo?Q=?UTF-8?Q?bar baz?=", "=?foo?Qbar baz", 0 },
63 { "=?foo?Q?=?UTF-8?Q?bar baz?=", "=?foo?Q?bar baz", 0 },
64 { "=?UTF-8?Q?bar ? baz?=", "=?UTF-8?Q?bar ? baz?=", 0 },
74 { "Test of ctext (=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)", "Test of ctext (ab)", 1 },
75 { "ctext with \\\"quoted\\\" pairs", "ctext with \"quoted\" pairs", 1 }
78 int main (int argc, char ** argv)
83 camel_test_init (argc, argv);
85 camel_test_start ("rfc2047 decoding");
87 for (i = 0; i < G_N_ELEMENTS (test1); i++) {
88 camel_test_push ("rfc2047 decoding[%d] '%s'", i, test1[i].encoded);
89 decoded = camel_header_decode_string (test1[i].encoded, "iso-8859-1");
90 check (decoded && strcmp (decoded, test1[i].decoded) == 0);
97 camel_test_start ("rfc2047 ctext decoding");
99 for (i = 0; i < G_N_ELEMENTS (test2); i++) {
100 camel_test_push ("rfc2047 ctext decoding[%d] '%s'", i, test2[i].encoded);
101 decoded = camel_header_format_ctext (test2[i].encoded, "iso-8859-1");
102 check (decoded && strcmp (decoded, test2[i].decoded) == 0);