diff options
Diffstat (limited to 'camel/tests/misc')
-rw-r--r-- | camel/tests/misc/.cvsignore | 12 | ||||
-rw-r--r-- | camel/tests/misc/Makefile.am | 27 | ||||
-rw-r--r-- | camel/tests/misc/README | 4 | ||||
-rw-r--r-- | camel/tests/misc/split.c | 113 | ||||
-rw-r--r-- | camel/tests/misc/url.c | 108 | ||||
-rw-r--r-- | camel/tests/misc/utf7.c | 106 |
6 files changed, 0 insertions, 370 deletions
diff --git a/camel/tests/misc/.cvsignore b/camel/tests/misc/.cvsignore deleted file mode 100644 index 7ef94ab5fa..0000000000 --- a/camel/tests/misc/.cvsignore +++ /dev/null @@ -1,12 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -.deps -*.lo -*.la -*.bb -*.bbg -*.da -*.gcov -url
\ 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 d3ed29f2e6..0000000000 --- a/camel/tests/misc/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ - -INCLUDES = \ - -I$(includedir) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/intl \ - -I$(top_srcdir)/e-util \ - -I$(top_srcdir)/camel \ - -I$(top_srcdir)/camel/tests/lib \ - -DG_LOG_DOMAIN=\"evolution-tests\" \ - $(CAMEL_CFLAGS) - -LDADD = \ - $(top_builddir)/camel/libcamel.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/camel/tests/lib/libcameltest.a \ - $(INTLLIBS) \ - $(EVOLUTION_MAIL_LIBS) - -check_PROGRAMS = \ - url \ - utf7 \ - split - -TESTS = url utf7 split - - - diff --git a/camel/tests/misc/README b/camel/tests/misc/README deleted file mode 100644 index e92f579cf6..0000000000 --- a/camel/tests/misc/README +++ /dev/null @@ -1,4 +0,0 @@ - -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 254b91974f..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 <e-util/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/url.c b/camel/tests/misc/url.c deleted file mode 100644 index adc6278bae..0000000000 --- a/camel/tests/misc/url.c +++ /dev/null @@ -1,108 +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:" } -}; -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 ("RFC1808 relative 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; -} |