diff options
author | JP Rosevear <jpr@src.gnome.org> | 2005-01-11 08:00:07 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2005-01-11 08:00:07 +0800 |
commit | fba011bf008443ee5130f1426aa65e11245cd84a (patch) | |
tree | 91793af1cfb21ec9bfea5579abb65ea6f73223b2 /camel/tests/misc | |
parent | c60c4bf7c4590b850d589d79ac44d057323a429f (diff) | |
download | gsoc2013-evolution-fba011bf008443ee5130f1426aa65e11245cd84a.tar gsoc2013-evolution-fba011bf008443ee5130f1426aa65e11245cd84a.tar.gz gsoc2013-evolution-fba011bf008443ee5130f1426aa65e11245cd84a.tar.bz2 gsoc2013-evolution-fba011bf008443ee5130f1426aa65e11245cd84a.tar.lz gsoc2013-evolution-fba011bf008443ee5130f1426aa65e11245cd84a.tar.xz gsoc2013-evolution-fba011bf008443ee5130f1426aa65e11245cd84a.tar.zst gsoc2013-evolution-fba011bf008443ee5130f1426aa65e11245cd84a.zip |
Kill dead files
svn path=/trunk/; revision=28342
Diffstat (limited to 'camel/tests/misc')
-rw-r--r-- | camel/tests/misc/.cvsignore | 14 | ||||
-rw-r--r-- | camel/tests/misc/Makefile.am | 28 | ||||
-rw-r--r-- | camel/tests/misc/README | 5 | ||||
-rw-r--r-- | camel/tests/misc/split.c | 113 | ||||
-rw-r--r-- | camel/tests/misc/test2.c | 121 | ||||
-rw-r--r-- | camel/tests/misc/url-scan.c | 132 | ||||
-rw-r--r-- | camel/tests/misc/url.c | 123 | ||||
-rw-r--r-- | camel/tests/misc/utf7.c | 106 |
8 files changed, 0 insertions, 642 deletions
diff --git a/camel/tests/misc/.cvsignore b/camel/tests/misc/.cvsignore deleted file mode 100644 index fbb8316a8b..0000000000 --- a/camel/tests/misc/.cvsignore +++ /dev/null @@ -1,14 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -.deps -*.lo -*.la -*.bb -*.bbg -*.da -*.gcov -split -url -utf7
\ No newline at end of file diff --git a/camel/tests/misc/Makefile.am b/camel/tests/misc/Makefile.am deleted file mode 100644 index 1be915e3f0..0000000000 --- a/camel/tests/misc/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ - -INCLUDES = \ - -I$(includedir) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/intl \ - -I$(top_srcdir)/camel \ - -I$(top_srcdir)/camel/tests/lib \ - -DG_LOG_DOMAIN=\"evolution-tests\" \ - $(CAMEL_CFLAGS) - -LDADD = \ - $(top_builddir)/camel/libcamel-provider.la \ - $(top_builddir)/camel/libcamel.la \ - $(top_builddir)/libedataserver/libedataserver-${BASE_VERSION}.la \ - $(top_builddir)/camel/tests/lib/libcameltest.a \ - $(INTLLIBS) - -check_PROGRAMS = \ - url \ - url-scan \ - utf7 \ - split \ - test2 - -TESTS = url utf7 split url-scan test2 - - - diff --git a/camel/tests/misc/README b/camel/tests/misc/README deleted file mode 100644 index 6b8f4a22f2..0000000000 --- a/camel/tests/misc/README +++ /dev/null @@ -1,5 +0,0 @@ - -test2 rfc2184 multipart/i18n parameters -url URL parsing -utf7 UTF7 and UTF8 processing -split word splitting for searching diff --git a/camel/tests/misc/split.c b/camel/tests/misc/split.c deleted file mode 100644 index 4fa8d18ea9..0000000000 --- a/camel/tests/misc/split.c +++ /dev/null @@ -1,113 +0,0 @@ -#include <config.h> - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <glib.h> -#include <libedataserver/e-sexp.h> -#include <camel/camel-exception.h> -#include <camel/camel-search-private.h> - -#include "camel-test.h" - -/* TODO: should put utf8 stuff here too */ - -static struct { - char *word; - int count; - struct { - char *word; - int type; - } splits[5]; -} split_tests[] = { - { "simple", 1, { { "simple", CAMEL_SEARCH_WORD_SIMPLE } } }, - { "two words", 2, { { "two", CAMEL_SEARCH_WORD_SIMPLE }, {"words" , CAMEL_SEARCH_WORD_SIMPLE } } }, - { "compl;ex", 1, { { "compl;ex", CAMEL_SEARCH_WORD_COMPLEX } } }, - { "compl;ex simple", 2, { { "compl;ex", CAMEL_SEARCH_WORD_COMPLEX} , {"simple", CAMEL_SEARCH_WORD_SIMPLE} } }, - { "\"quoted\"", 1, { { "quoted", CAMEL_SEARCH_WORD_SIMPLE } } }, - { "\"quoted double\"", 1, { { "quoted double", CAMEL_SEARCH_WORD_COMPLEX } } }, - { "\"quoted double\" compl;ex", 2, { { "quoted double", CAMEL_SEARCH_WORD_COMPLEX }, { "compl;ex", CAMEL_SEARCH_WORD_COMPLEX } } }, - { "\"quoted double \\\" escaped\"", 1, { { "quoted double \" escaped", CAMEL_SEARCH_WORD_COMPLEX } } }, - { "\"quoted\\\"double\" \\\" escaped\\\"", 3, { { "quoted\"double", CAMEL_SEARCH_WORD_COMPLEX }, {"\"", CAMEL_SEARCH_WORD_COMPLEX}, { "escaped\"", CAMEL_SEARCH_WORD_COMPLEX } } }, - { "\\\"escaped", 1, { { "\"escaped", CAMEL_SEARCH_WORD_COMPLEX } } }, - -}; -#define SPLIT_LENGTH (sizeof(split_tests)/sizeof(split_tests[0])) - -static struct { - char *word; - int count; - struct { - char *word; - int type; - } splits[5]; -} simple_tests[] = { - { "simple", 1, { {"simple", CAMEL_SEARCH_WORD_SIMPLE } } }, - { "simpleCaSe", 1, { { "simplecase", CAMEL_SEARCH_WORD_SIMPLE } } }, - { "two words", 2, { { "two", CAMEL_SEARCH_WORD_SIMPLE }, { "words", CAMEL_SEARCH_WORD_SIMPLE } } }, - { "two wordscAsE", 2, { { "two", CAMEL_SEARCH_WORD_SIMPLE} , { "wordscase", CAMEL_SEARCH_WORD_SIMPLE } } }, - { "compl;ex", 2, { { "compl", CAMEL_SEARCH_WORD_SIMPLE }, { "ex", CAMEL_SEARCH_WORD_SIMPLE } } }, - { "compl;ex simple", 3, { { "compl", CAMEL_SEARCH_WORD_SIMPLE }, { "ex", CAMEL_SEARCH_WORD_SIMPLE }, { "simple", CAMEL_SEARCH_WORD_SIMPLE } } }, - { "\"quoted compl;ex\" simple", 4, { { "quoted", CAMEL_SEARCH_WORD_SIMPLE}, { "compl", CAMEL_SEARCH_WORD_SIMPLE }, { "ex", CAMEL_SEARCH_WORD_SIMPLE }, { "simple", CAMEL_SEARCH_WORD_SIMPLE } } }, - { "\\\" \"quoted\"compl;ex\" simple", 4, { { "quoted", CAMEL_SEARCH_WORD_SIMPLE}, { "compl", CAMEL_SEARCH_WORD_SIMPLE }, { "ex", CAMEL_SEARCH_WORD_SIMPLE }, { "simple", CAMEL_SEARCH_WORD_SIMPLE } } }, -}; - -#define SIMPLE_LENGTH (sizeof(simple_tests)/sizeof(simple_tests[0])) - -int -main (int argc, char **argv) -{ - int i, j; - struct _camel_search_words *words, *tmp; - - camel_test_init(argc, argv); - - camel_test_start("Search splitting"); - - for (i=0; i<SPLIT_LENGTH; i++) { - camel_test_push("split %d '%s'", i, split_tests[i].word); - - words = camel_search_words_split(split_tests[i].word); - check(words != NULL); - check_msg(words->len == split_tests[i].count, "words->len = %d, count = %d", words->len, split_tests[i].count); - - for (j=0;j<words->len;j++) { - check_msg(strcmp(split_tests[i].splits[j].word, words->words[j]->word) == 0, - "'%s' != '%s'", split_tests[i].splits[j].word, words->words[j]->word); - check(split_tests[i].splits[j].type == words->words[j]->type); - } - - camel_search_words_free(words); - camel_test_pull(); - } - - camel_test_end(); - - camel_test_start("Search splitting - simple"); - - for (i=0; i<SIMPLE_LENGTH; i++) { - camel_test_push("simple split %d '%s'", i, simple_tests[i].word); - - tmp = camel_search_words_split(simple_tests[i].word); - check(tmp != NULL); - - words = camel_search_words_simple(tmp); - check(words != NULL); - check_msg(words->len == simple_tests[i].count, "words->len = %d, count = %d", words->len, simple_tests[i].count); - - for (j=0;j<words->len;j++) { - check_msg(strcmp(simple_tests[i].splits[j].word, words->words[j]->word) == 0, - "'%s' != '%s'", simple_tests[i].splits[j].word, words->words[j]->word); - check(simple_tests[i].splits[j].type == words->words[j]->type); - } - - camel_search_words_free(words); - camel_search_words_free(tmp); - camel_test_pull(); - } - - camel_test_end(); - - return 0; -} diff --git a/camel/tests/misc/test2.c b/camel/tests/misc/test2.c deleted file mode 100644 index a802392e91..0000000000 --- a/camel/tests/misc/test2.c +++ /dev/null @@ -1,121 +0,0 @@ - - -#include <config.h> - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <camel/camel-object.h> -#include <camel/camel-mime-utils.h> - -#include "camel-test.h" - -/* NB: We know which order the params will be decoded in, plain in the order they come, - and rfc2184 encoded following those, sorted lexigraphically */ -struct { - char *list; - int count; - char *params[8]; -} test1[] = { - { "; charset=\"iso-8859-1\"", - 1, - { "charset", "iso-8859-1" }, }, - { "; charset=iso-8859-1", - 1, - { "charset", "iso-8859-1" }, }, - { "; charset=\"iso-8859-1\"; boundary=\"foo\"", - 2, - { "charset", "iso-8859-1", - "boundary", "foo" }, }, - { "; charset*1 = 8859; charset*0=\"iso-8859-1'en'iso-\";charset*2=\"-1\" ", - 1, - { "charset", "iso-8859-1" }, }, - { "; charset*1 = 8859; boundary=foo; charset*0=\"iso-8859-1'en'iso-\";charset*2=\"-1\" ", - 2, - { "boundary", "foo", - "charset", "iso-8859-1", }, }, - { "; charset*1 = 8859; boundary*0=f; charset*0=\"iso-8859-1'en'iso-\"; boundary*2=\"o\" ; charset*2=\"-1\"; boundary*1=o ", - 2, - { "boundary", "foo", - "charset", "iso-8859-1", }, }, - { "; charset*1 = 8859; boundary*0=\"iso-8859-1'en'f\"; charset*0=\"iso-8859-1'en'iso-\"; boundary*2=\"o\" ; charset*2=\"-1\"; boundary*1=o ", - 2, - { "boundary", "foo", - "charset", "iso-8859-1", }, }, -}; - -struct { - int count; - char *params[8]; - char *list; -} test2[] = { - { 1, - { "name", "Doul\xC3\xADk01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123457890123456789123456789" }, - ";\n" - "\tname*0*=iso-8859-1''Doul%EDk012345678901234567890123456789012345678901234;\n" - "\tname*1*=56789012345678901234567890123456789012345678901234567890123457890;\n" - "\tname*2*=123456789123456789" }, - { 1, - { "name", "\"%$#@ special chars?;; !" }, - "; name=\"\\\"%$#@ special chars?;; !\"" }, - { 1, - { "name", "\"%$#@ special chars?;; !\xC3\xAD" }, - "; name*=iso-8859-1''%22%25$#%40%20special%20chars%3F%3B%3B%20!%ED" }, -}; - -int -main (int argc, char **argv) -{ - int i, j; - - camel_test_init(argc, argv); - - camel_test_start("Param list decoding"); - - for (i=0;i<sizeof(test1)/sizeof(test1[0]);i++) { - struct _camel_header_param *head, *node; - - camel_test_push("param decoding[%d] '%s'", i, test1[i].list); - head = camel_header_param_list_decode(test1[i].list); - check(head != NULL); - node = head; - for (j=0;j<test1[i].count;j++) { - check_msg(node != NULL, "didn't find all params"); - check(strcmp(node->name, test1[i].params[j*2]) == 0); - check(strcmp(node->value, test1[i].params[j*2+1]) == 0); - node = node->next; - } - check_msg(node == NULL, "found more params than should have"); - camel_header_param_list_free(head); - camel_test_pull(); - } - - camel_test_end(); - - camel_test_start("Param list encoding"); - - for (i=0;i<sizeof(test2)/sizeof(test2[0]);i++) { - struct _camel_header_param *head = NULL, *scan; - char *text; - - camel_test_push("param encoding[%d]", i); - - for (j=0;j<test2[i].count;j++) - camel_header_set_param(&head, test2[i].params[j*2], test2[i].params[j*2+1]); - scan = head; - for (j=0;scan;j++) - scan = scan->next; - check(j == test2[i].count); - - text = camel_header_param_list_format(head); - check(strcmp(text, test2[i].list) == 0); - camel_header_param_list_free(head); - - camel_test_pull(); - } - - camel_test_end(); - - return 0; -} diff --git a/camel/tests/misc/url-scan.c b/camel/tests/misc/url-scan.c deleted file mode 100644 index a7bbf51cf5..0000000000 --- a/camel/tests/misc/url-scan.c +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <camel/camel-mime-filter-tohtml.h> - -#include "camel-test.h" - -struct { - char *text, *url; -} url_tests[] = { - { "bob@foo.com", "mailto:bob@foo.com" }, - { "Ends with bob@foo.com", "mailto:bob@foo.com" }, - { "bob@foo.com at start", "mailto:bob@foo.com" }, - { "bob@foo.com.", "mailto:bob@foo.com" }, - { "\"bob@foo.com\"", "mailto:bob@foo.com" }, - { "<bob@foo.com>", "mailto:bob@foo.com" }, - { "(bob@foo.com)", "mailto:bob@foo.com" }, - { "bob@foo.com, 555-9999", "mailto:bob@foo.com" }, - { "|bob@foo.com|555-9999|", "mailto:bob@foo.com" }, - { "bob@ no match bob@", NULL }, - { "@foo.com no match @foo.com", NULL }, - { "\"bob\"@foo.com", NULL }, - { "M@ke money fast!", NULL }, - { "ASCII art @_@ @>->-", NULL }, - - { "http://www.foo.com", "http://www.foo.com" }, - { "Ends with http://www.foo.com", "http://www.foo.com" }, - { "http://www.foo.com at start", "http://www.foo.com" }, - { "http://www.foo.com.", "http://www.foo.com" }, - { "http://www.foo.com/.", "http://www.foo.com/" }, - { "<http://www.foo.com>", "http://www.foo.com" }, - { "(http://www.foo.com)", "http://www.foo.com" }, - { "http://www.foo.com, 555-9999", "http://www.foo.com" }, - { "|http://www.foo.com|555-9999|", "http://www.foo.com" }, - { "foo http://www.foo.com/ bar", "http://www.foo.com/" }, - { "foo http://www.foo.com/index.html bar", "http://www.foo.com/index.html" }, - { "foo http://www.foo.com/q?99 bar", "http://www.foo.com/q?99" }, - { "foo http://www.foo.com/;foo=bar&baz=quux bar", "http://www.foo.com/;foo=bar&baz=quux" }, - { "foo http://www.foo.com/index.html#anchor bar", "http://www.foo.com/index.html#anchor" }, - { "http://www.foo.com/index.html; foo", "http://www.foo.com/index.html" }, - { "http://www.foo.com/index.html: foo", "http://www.foo.com/index.html" }, - { "http://www.foo.com/index.html-- foo", "http://www.foo.com/index.html" }, - { "http://www.foo.com/index.html?", "http://www.foo.com/index.html" }, - { "http://www.foo.com/index.html!", "http://www.foo.com/index.html" }, - { "\"http://www.foo.com/index.html\"", "http://www.foo.com/index.html" }, - { "'http://www.foo.com/index.html'", "http://www.foo.com/index.html" }, - { "http://bob@www.foo.com/bar/baz/", "http://bob@www.foo.com/bar/baz/" }, - { "http no match http", NULL }, - { "http: no match http:", NULL }, - { "http:// no match http://", NULL }, - { "unrecognized://bob@foo.com/path", "mailto:bob@foo.com" }, - - { "src/www.c", NULL }, - { "Ewwwwww.Gross.", NULL }, - -}; - -static int num_url_tests = G_N_ELEMENTS (url_tests); - -int main (int argc, char **argv) -{ - char *html, *url, *p; - int i, errors = 0; - guint32 flags; - - camel_test_init (argc, argv); - - camel_test_start ("URL scanning"); - - flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES; - for (i = 0; i < num_url_tests; i++) { - camel_test_push ("'%s' => '%s'", url_tests[i].text, url_tests[i].url ? url_tests[i].url : "None"); - - html = camel_text_to_html (url_tests[i].text, flags, 0); - - url = strstr (html, "href=\""); - if (url) { - url += 6; - p = strchr (url, '"'); - if (p) - *p = '\0'; - - while ((p = strstr (url, "&"))) - memmove (p + 1, p + 5, strlen (p + 5) + 1); - } - - if ((url && (!url_tests[i].url || strcmp (url, url_tests[i].url) != 0)) || - (!url && url_tests[i].url)) { - printf ("FAILED on \"%s\" -> %s\n (got %s)\n\n", - url_tests[i].text, - url_tests[i].url ? url_tests[i].url : "(nothing)", - url ? url : "(nothing)"); - errors++; - } - - g_free (html); - } - - printf ("\n%d errors\n", errors); - - camel_test_end (); - - return errors; -} diff --git a/camel/tests/misc/url.c b/camel/tests/misc/url.c deleted file mode 100644 index c2db806621..0000000000 --- a/camel/tests/misc/url.c +++ /dev/null @@ -1,123 +0,0 @@ -#include <config.h> - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <camel/camel-url.h> -#include <camel/camel-exception.h> - -#include "camel-test.h" - -char *base = "http://a/b/c/d;p?q#f"; - -struct { - char *url_string, *result; -} tests[] = { - { "g:h", "g:h" }, - { "g", "http://a/b/c/g" }, - { "./g", "http://a/b/c/g" }, - { "g/", "http://a/b/c/g/" }, - { "/g", "http://a/g" }, - { "//g", "http://g" }, - { "?y", "http://a/b/c/d;p?y" }, - { "g?y", "http://a/b/c/g?y" }, - { "g?y/./x", "http://a/b/c/g?y/./x" }, - { "#s", "http://a/b/c/d;p?q#s" }, - { "g#s", "http://a/b/c/g#s" }, - { "g#s/./x", "http://a/b/c/g#s/./x" }, - { "g?y#s", "http://a/b/c/g?y#s" }, - { ";x", "http://a/b/c/d;x" }, - { "g;x", "http://a/b/c/g;x" }, - { "g;x?y#s", "http://a/b/c/g;x?y#s" }, - { ".", "http://a/b/c/" }, - { "./", "http://a/b/c/" }, - { "..", "http://a/b/" }, - { "../", "http://a/b/" }, - { "../g", "http://a/b/g" }, - { "../..", "http://a/" }, - { "../../", "http://a/" }, - { "../../g", "http://a/g" }, - { "", "http://a/b/c/d;p?q#f" }, - { "../../../g", "http://a/../g" }, - { "../../../../g", "http://a/../../g" }, - { "/./g", "http://a/./g" }, - { "/../g", "http://a/../g" }, - { "g.", "http://a/b/c/g." }, - { ".g", "http://a/b/c/.g" }, - { "g..", "http://a/b/c/g.." }, - { "..g", "http://a/b/c/..g" }, - { "./../g", "http://a/b/g" }, - { "./g/.", "http://a/b/c/g/" }, - { "g/./h", "http://a/b/c/g/h" }, - { "g/../h", "http://a/b/c/h" }, - { "http:g", "http:g" }, - { "http:", "http:" }, - - /* (not from rfc 1808) */ - { "sendmail:", "sendmail:" }, - { "mbox:/var/mail/user", "mbox:/var/mail/user" }, - { "pop://user@host", "pop://user@host" }, - { "pop://user@host:99", "pop://user@host:99" }, - { "pop://user:password@host", "pop://user:password@host" }, - { "pop://user:password@host:99", "pop://user:password@host:99" }, - { "pop://user;auth=APOP@host", "pop://user;auth=APOP@host" }, - { "pop://user@host/;keep_on_server", "pop://user@host/;keep_on_server" }, - { "pop://user@host/;keep_on_server=1", "pop://user@host/;keep_on_server=1" }, - { "pop://us%65r@host", "pop://user@host" }, - { "pop://us%40r@host", "pop://us%40r@host" }, - { "pop://us%3ar@host", "pop://us%3ar@host" }, - { "pop://us%2fr@host", "pop://us%2fr@host" } -}; -int num_tests = sizeof (tests) / sizeof (tests[0]); - -int -main (int argc, char **argv) -{ - CamelURL *base_url, *url; - CamelException ex; - char *url_string; - int i; - - camel_test_init (argc, argv); - - camel_test_start ("URL parsing"); - - camel_test_push ("base URL parsing"); - camel_exception_init (&ex); - base_url = camel_url_new (base, &ex); - if (!base_url) { - camel_test_fail ("Could not parse %s: %s\n", base, - camel_exception_get_description (&ex)); - } - camel_test_pull (); - - camel_test_push ("base URL unparsing"); - url_string = camel_url_to_string (base_url, 0); - if (strcmp (url_string, base) != 0) { - camel_test_fail ("URL <%s> unparses to <%s>\n", - base, url_string); - } - camel_test_pull (); - g_free (url_string); - - for (i = 0; i < num_tests; i++) { - camel_test_push ("<%s> + <%s> = <%s>?", base, tests[i].url_string, tests[i].result); - url = camel_url_new_with_base (base_url, tests[i].url_string); - if (!url) { - camel_test_fail ("could not parse"); - camel_test_pull (); - continue; - } - - url_string = camel_url_to_string (url, 0); - if (strcmp (url_string, tests[i].result) != 0) - camel_test_fail ("got <%s>!", url_string); - g_free (url_string); - camel_test_pull (); - } - - camel_test_end (); - - return 0; -} diff --git a/camel/tests/misc/utf7.c b/camel/tests/misc/utf7.c deleted file mode 100644 index dec0f4b7e5..0000000000 --- a/camel/tests/misc/utf7.c +++ /dev/null @@ -1,106 +0,0 @@ -#include <config.h> - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <glib.h> -#include <camel/camel-utf8.h> -#include <camel/camel-exception.h> - -#include "camel-test.h" - -static struct { - unsigned char *utf8; - char *utf7; - guint32 unicode[200]; -} tests[] = { - /* the escape char */ - { "&", "&-", - { 0x0026, } }, - /* part of set D */ - { "+", "+", - { 0x002b, } }, - { "plain ascii text", "plain ascii text", - { 0x0070, 0x006c, 0x0061, 0x0069, 0x006e, 0x0020, 0x0061, 0x0073, 0x0063, 0x0069, 0x0069, 0x0020, 0x0074, 0x0065, 0x0078, 0x0074, } }, - /* part of set O */ - { "'(),-./:?", "'(),-./:?", - { 0x0027, 0x0028, 0x0029, 0x002c, 0x002d, 0x002e, 0x002f, 0x003a, 0x003f, } }, - { "!\"#$%*+-;<=>@[]^_`{|}", "!\"#$%*+-;<=>@[]^_`{|}", - { 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x002a, 0x002b, 0x002d, 0x003b, 0x003c, 0x003d, 0x003e, 0x0040, 0x005b, 0x005d, 0x005e, 0x005f, 0x0060, 0x007b, 0x007c, 0x007d, } }, - /* example strings from rfc1642 (modified for imap utf7) */ - { "A\xe2\x89\xa2\xce\x91" ".", "A&ImIDkQ-.", - { 0x0041, 0x2262, 0x0391, 0x002e, } }, - { "Hi Mum \xe2\x98\xba!", "Hi Mum &Jjo-!", - { 0x0048, 0x0069, 0x0020, 0x004d, 0x0075, 0x006d, 0x0020, 0x263a, 0x0021, } }, - { "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e", "&ZeVnLIqe-", - { 0x65e5, 0x672c, 0x8a9e, } }, - { "Item 3 is \xc2\xa3" "1.", "Item 3 is &AKM-1.", - { 0x0049, 0x0074, 0x0065, 0x006d, 0x0020, 0x0033, 0x0020, 0x0069, 0x0073, 0x0020, 0x00a3, 0x0031, 0x002e, } }, - { "\"The sayings of Confucius,\" James R. Ware, trans. \xe5\x8f\xb0\xe5\x8c\x97:\xe6\x96\x87\xe8\x87\xb4\xe5\x87\xba\xe7\x89\x88\xe7\xa4\xbe, 1980. (Chinese text with English translation)\xe5\x9b\x9b\xe6\x9b\xb8\xe4\xba\x94\xe7\xb6\x93, \xe5\xae\x8b\xe5\x85\x83\xe4\xba\xba\xe6\xb3\xa8, \xe5\x8c\x97\xe4\xba\xac: \xe4\xb8\xad\xe5\x9c\x8b\xe6\x9b\xb8\xe5\xba\x97, 1990.", - "\"The sayings of Confucius,\" James R. Ware, trans. &U,BTFw-:&ZYeB9FH6ckh5Pg-, 1980. (Chinese text with English translation)&Vttm+E6UfZM-, &W4tRQ066bOg-, &UxdOrA-: &Ti1XC2b4Xpc-, 1990.", - { 0x0022, 0x0054, 0x0068, 0x0065, 0x0020, 0x0073, 0x0061, 0x0079, 0x0069, 0x006e, 0x0067, 0x0073, 0x0020, 0x006f, 0x0066, 0x0020, 0x0043, 0x006f, 0x006e, 0x0066, 0x0075, 0x0063, 0x0069, 0x0075, 0x0073, 0x002c, 0x0022, 0x0020, 0x004a, 0x0061, 0x006d, 0x0065, 0x0073, 0x0020, 0x0052, 0x002e, 0x0020, 0x0057, 0x0061, 0x0072, 0x0065, 0x002c, 0x0020, 0x0074, 0x0072, 0x0061, 0x006e, 0x0073, 0x002e, 0x0020, 0x0020, 0x53f0, 0x5317, 0x003a, 0x6587, 0x81f4, 0x51fa, 0x7248, 0x793e, 0x002c, 0x0020, 0x0031, 0x0039, 0x0038, 0x0030, 0x002e, 0x0020, 0x0020, 0x0028, 0x0043, 0x0068, 0x0069, 0x006e, 0x0065, 0x0073, 0x0065, 0x0020, 0x0074, 0x0065, 0x0078, 0x0074, 0x0020, 0x0077, 0x0069, 0x0074, 0x0068, 0x0020, 0x0045, 0x006e, 0x0067, 0x006c, 0x0069, 0x0073, 0x0068, 0x0020, 0x0074, 0x0072, 0x0061, 0x006e, 0x0073, 0x006c, 0x0061, 0x0074, 0x0069, 0x006f, 0x006e, 0x0029, 0x56db, 0x66f8, 0x4e94, 0x7d93, 0x002c, 0x0020, 0x5b8b, 0x5143, 0x4eba, 0x6ce8, 0x002c, 0x0020, 0x5317, 0x4eac, 0x003a, 0x0020, 0x0020, 0x4e2d, 0x570b, 0x66f8, 0x5e97, 0x002c, 0x0020, 0x0031, 0x0039, 0x0039, 0x0030, 0x002e, } }, -}; -#define TESTS_LENGTH (sizeof(tests)/sizeof(tests[0])) - -int -main (int argc, char **argv) -{ - char *utf8, *utf7, *p; - int i, j; - guint32 u; - char utf8enc[256]; - GString *out; - - camel_test_init(argc, argv); - - out = g_string_new(""); - - camel_test_start("UTF8, UTF7 RFC1642+RFC2060"); - - for (i=0; i<TESTS_LENGTH; i++) { - - camel_test_push("%2d: %s utf8 decode", i, tests[i].utf7); - p = tests[i].utf8; - j = 0; - do { - u = camel_utf8_getc((const unsigned char **)&p); - check(u == tests[i].unicode[j]); - j++; - } while (u); - camel_test_pull(); - - camel_test_push("%2d: %s utf7->utf8", i, tests[i].utf7); - utf8 = camel_utf7_utf8(tests[i].utf7); - check_msg(strcmp(utf8, tests[i].utf8) == 0, "utf8 = '%s'", utf8); - camel_test_pull(); - - camel_test_push("%2d: %s utf7->utf8->utf7", i, tests[i].utf7); - utf7 = camel_utf8_utf7(utf8); - check_msg(strcmp(utf7, tests[i].utf7) == 0, "utf7 = '%s'", utf7); - camel_test_pull(); - - g_free(utf7); - g_free(utf8); - - camel_test_push("%2d: %s utf8 encode", i, tests[i].utf7); - - g_string_truncate(out, 0); - p = utf8enc; - j = 0; - do { - u = tests[i].unicode[j++]; - camel_utf8_putc((unsigned char **)&p, u); - g_string_append_u(out, u); - } while (u); - - check(strcmp(utf8enc, out->str) == 0); - check(strcmp(utf8enc, tests[i].utf8) == 0); - - camel_test_pull(); - } - - camel_test_end(); - - return 0; -} |