aboutsummaryrefslogtreecommitdiffstats
path: root/camel/tests/lib
diff options
context:
space:
mode:
authornobody <nobody@localhost>2001-04-16 17:30:54 +0800
committernobody <nobody@localhost>2001-04-16 17:30:54 +0800
commit6e405ff38c1cc0715c5e14989c946a5f4f1249f7 (patch)
treeaaa46c1cf6c9a87e8f291ef7673bd9463803e8c9 /camel/tests/lib
parent75a16468d369f58587f27ab4655fbe1c1091fc95 (diff)
downloadgsoc2013-evolution-radioactive-1_2_1.tar
gsoc2013-evolution-radioactive-1_2_1.tar.gz
gsoc2013-evolution-radioactive-1_2_1.tar.bz2
gsoc2013-evolution-radioactive-1_2_1.tar.lz
gsoc2013-evolution-radioactive-1_2_1.tar.xz
gsoc2013-evolution-radioactive-1_2_1.tar.zst
gsoc2013-evolution-radioactive-1_2_1.zip
This commit was manufactured by cvs2svn to create tagradioactive-1_2_1
'radioactive-1_2_1'. svn path=/tags/radioactive-1_2_1/; revision=9372
Diffstat (limited to 'camel/tests/lib')
-rw-r--r--camel/tests/lib/.cvsignore12
-rw-r--r--camel/tests/lib/Makefile.am13
-rw-r--r--camel/tests/lib/address-data.h93
-rw-r--r--camel/tests/lib/addresses.c51
-rw-r--r--camel/tests/lib/addresses.h5
-rw-r--r--camel/tests/lib/camel-test.c350
-rw-r--r--camel/tests/lib/camel-test.h68
-rw-r--r--camel/tests/lib/folders.c526
-rw-r--r--camel/tests/lib/folders.h20
-rw-r--r--camel/tests/lib/messages.c153
-rw-r--r--camel/tests/lib/messages.h12
-rw-r--r--camel/tests/lib/streams.c244
-rw-r--r--camel/tests/lib/streams.h12
13 files changed, 0 insertions, 1559 deletions
diff --git a/camel/tests/lib/.cvsignore b/camel/tests/lib/.cvsignore
deleted file mode 100644
index ba98331a6d..0000000000
--- a/camel/tests/lib/.cvsignore
+++ /dev/null
@@ -1,12 +0,0 @@
-.deps
-Makefile
-Makefile.in
-.libs
-.deps
-*.lo
-*.la
-temp-test
-*.bb
-*.bbg
-*.da
-*.gcov
diff --git a/camel/tests/lib/Makefile.am b/camel/tests/lib/Makefile.am
deleted file mode 100644
index ea51a2c28a..0000000000
--- a/camel/tests/lib/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-
-INCLUDES = -I$(includedir)
-
-check_LIBRARIES = libcameltest.a
-
-libcameltest_a_SOURCES = \
- camel-test.c camel-test.h \
- messages.c messages.h \
- addresses.c addresses.h \
- folders.c folders.h \
- streams.c streams.h \
- address-data.h
-
diff --git a/camel/tests/lib/address-data.h b/camel/tests/lib/address-data.h
deleted file mode 100644
index acecac596a..0000000000
--- a/camel/tests/lib/address-data.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* BE WARY of editing this file with emacs.
- Otherwise it might be smart and try to re-encode everything, which
- you really do not want
-*/
-
-static struct _a {
- int count;
- char *addr;
- char *utf8; /* the utf8 in this table was generated by camel itself. As a result i'm making the assumption it
- was right when it was created. It also depends on the format of ::format(),. which is likely to
- change, to handle other bugs ! */
-} test_address[] = {
- { 1, "\"=?ISO-8859-1?Q?David_Guti=E9rrez_Magallanes?=\" <david@iiia.csic.es>", "David Gutiérrez Magallanes <david@iiia.csic.es>" },
- { 1, "\"=?iso-8859-1?Q?Jos=E9?= Antonio Milke G.\" <gerencia@ovoplus.com>", "José Antonio Milke G. <gerencia@ovoplus.com>" },
- { 1, "\"=?iso-8859-2?Q?Hi-Fi_Internert_market_=3D_1.Virtu=E1ln=ED_Internetov=E9_H?= =?iso-8859-2?Q?i-Fi_Studio?=\" <hifimarket@atlas.cz>", "Hi-Fi Internert market = 1.Virtuální Internetové Hi-Fi Studio <hifimarket@atlas.cz>" },
- { 3, "\"James M. Cape\" <jcape@jcinteractive.com>, =?iso-8859-1?Q?Joaqu=EDn_Cuenca_Abela?= <cuenca@ie2.u-psud.fr>, gnome-hackers@nuclecu.unam.mx", "James M. Cape <jcape@jcinteractive.com>, Joaquín Cuenca Abela <cuenca@ie2.u-psud.fr>, gnome-hackers@nuclecu.unam.mx" },
- { 1, "=?ISO-8859-1?Q?David_Guti=E9rrez_Magallanes?= <david@iiia.csic.es>", "David Gutiérrez Magallanes <david@iiia.csic.es>" },
- { 1, "=?ISO-8859-2?Q?Tomasz_K=B3oczko?= <kloczek@rudy.mif.pg.gda.pl>", "Tomasz Kłoczko <kloczek@rudy.mif.pg.gda.pl>" },
- { 1, "=?ISO-8859-2?Q?Vladim=EDr_Solnick=FD?= <vs@utia.cas.cz>", "Vladimír Solnický <vs@utia.cas.cz>" },
- { 1, "=?iso-8859-1?Q?=22S=F6rensen=2C_Daniel=22?= <dasar@wmdata.com>", "\"Sörensen, Daniel\" <dasar@wmdata.com>" },
- { 1, "=?iso-8859-1?Q?=C1=C2=AAQ=A7=CA?= <dennys@iim.nctu.edu.tw>", "ÁªQ§Ê <dennys@iim.nctu.edu.tw>" },
- { 1, "=?iso-8859-1?Q?=C1=C2=AAQ=A7=CA?= <dennys@news.iim.nctu.edu.tw>", "ÁªQ§Ê <dennys@news.iim.nctu.edu.tw>" },
- { 1, "=?iso-8859-1?Q?=C1kos?= Valentinyi <A.Valentinyi@soton.ac.uk>", "Ákos Valentinyi <A.Valentinyi@soton.ac.uk>" },
- { 1, "=?iso-8859-1?Q?Joaqu=EDn?= Cuenca Abela <cuenca@ie2.u-psud.fr>", "Joaquín Cuenca Abela <cuenca@ie2.u-psud.fr>" },
- { 2, "=?iso-8859-1?Q?Joaqu=EDn?= Cuenca Abela <cuenca@ie2.u-psud.fr>, gnome-hackers@nuclecu.unam.mx", "Joaquín Cuenca Abela <cuenca@ie2.u-psud.fr>, gnome-hackers@nuclecu.unam.mx" },
- { 1, "=?iso-8859-1?Q?Joaqu=EDn_Cuenca_Abela?= <cuenca@celium.net>", "Joaquín Cuenca Abela <cuenca@celium.net>" },
- { 1, "=?iso-8859-1?Q?Juantom=E1s=20Garc=EDa?= <juantomas@lared.es>", "Juantomás García <juantomas@lared.es>" },
- { 1, "=?iso-8859-1?Q?Kenneth_ll=E9phaane_Christiansen?= <kenneth@ripen.dk>", "Kenneth lléphaane Christiansen <kenneth@ripen.dk>" },
- { 1, "=?iso-8859-1?Q?Kjell_Tage_=D8hman?= <tage@ohman.no>", "Kjell Tage Øhman <tage@ohman.no>" },
- { 1, "=?iso-8859-1?Q?Martin_Norb=E4ck?= <d95mback@dtek.chalmers.se>", "Martin Norbäck <d95mback@dtek.chalmers.se>" },
- { 1, "=?iso-8859-1?Q?P=E5llen?= <pollen@astrakan.hig.se>", "Pållen <pollen@astrakan.hig.se>" },
- { 1, "=?iso-8859-1?Q?Ville_P=E4tsi?= <drc@gnu.org>", "Ville Pätsi <drc@gnu.org>" },
- { 1, "=?iso-8859-1?q?Joaqu=EDn?= Cuenca Abela <cuenca@celium.net>", "Joaquín Cuenca Abela <cuenca@celium.net>" },
- { 1, "=?iso-8859-2?Q?Dra=BEen_Ka=E8ar?= <dave@srce.hr>", "Dražen Kačar <dave@srce.hr>" },
- /* yep this is right, this isn't valid so doesn't decode at all */
- { 1, "=?windows-1250?Q? \"Jaka Mo=E8nik\" ?= <jaka.mocnik@kiss.uni-lj.si>", "=?windows-1250?Q? Jaka Mo=E8nik ?= <jaka.mocnik@kiss.uni-lj.si>" },
- { 3, "George <jirka@5z.com>, Juantomas =?ISO-8859-1?Q?Garc=C3=83=C2=ADa?= <juantomas@lared.es>, gnome-hackers@gnome.org", "George <jirka@5z.com>, Juantomas García <juantomas@lared.es>, gnome-hackers@gnome.org" },
- { 7, "Jon Trowbridge <trow@emccta.com>, gnome-1.4-list@gnome.org, gnome-devel-list@gnome.org, gnome-hackers@gnome.org, Dom Lachowicz <cinamod@hotmail.com>, =?iso-8859-1?Q?Joaqu=EDn_Cuenca_Abela?= <cuenca@celium.net>, sam th <sam@uchicago.edu>", "Jon Trowbridge <trow@emccta.com>, gnome-1.4-list@gnome.org, gnome-devel-list@gnome.org, gnome-hackers@gnome.org, Dom Lachowicz <cinamod@hotmail.com>, Joaquín Cuenca Abela <cuenca@celium.net>, sam th <sam@uchicago.edu>" },
- { 6, "Jon Trowbridge <trow@emccta.com>, gnome-1.4-list@gnome.org, gnome-devel-list@gnome.org, gnome-hackers@gnome.org, Dom Lachowicz <cinamod@hotmail.com>, =?iso-8859-1?Q?Joaqu=EDn_Cuenca_Abela?= <cuenca@ie2.u-psud.fr>", "Jon Trowbridge <trow@emccta.com>, gnome-1.4-list@gnome.org, gnome-devel-list@gnome.org, gnome-hackers@gnome.org, Dom Lachowicz <cinamod@hotmail.com>, Joaquín Cuenca Abela <cuenca@ie2.u-psud.fr>" },
- { 1, "Kai =?iso-8859-1?Q?Gro=DFjohann?= <Kai.Grossjohann@CS.Uni-Dortmund.DE>", "Kai Großjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>" },
- { 1, "Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai =?iso-8859-1?q?Gro=DFjohann?=)", "Kai Großjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>" },
- { 1, "Rickard =?iso-8859-1?Q?Nordstr=F6m?= <rzi@ebox.tninet.se>", "Rickard Nordström <rzi@ebox.tninet.se>" },
- { 1, "Tomasz =?iso-8859-2?q?K=B3oczko?= <kloczek@rudy.mif.pg.gda.pl>", "Tomasz Kłoczko <kloczek@rudy.mif.pg.gda.pl>" },
- { 1, "VALCKE =?iso-8859-1?Q?C=E9dric?= <cvalcke@freesurf.fr>", "VALCKE Cédric <cvalcke@freesurf.fr>" },
- { 1, "Ville =?iso-8859-1?q?P=E4tsi?= <drc@gnu.org>", "Ville Pätsi <drc@gnu.org>" },
- { 1, "david@iiia.csic.es (=?ISO-8859-1?Q?David_Guti=E9rrez_Magallanes?=)", "David Gutiérrez Magallanes <david@iiia.csic.es>" },
- { 1, "kloczek@rudy.mif.pg.gda.pl (=?ISO-8859-2?Q?Tomasz_K=B3oczko?=)", "Tomasz Kłoczko <kloczek@rudy.mif.pg.gda.pl>" },
- { 1, "lassehp@imv.aau.dk (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)", "Lasse Hillerøe Petersen <lassehp@imv.aau.dk>" },
- { 1, "ysato@etl.go.jp (Yutaka Sato =?ISO-2022-JP?B?GyRAOjRGI0stGyhK?=)", "Yutaka Sato 佐藤豊 <ysato@etl.go.jp>" },
-};
-
-static struct _l {
- char *type;
- char *line;
-} test_lines[] = {
- /* commented out unsupported charsets - FIXME: camel should somehow handle this, although it can't really of course */
- /*{ "windows-1251", " .\n ?" },*/
- { "iso-8859-1", "Omple les miniatures de la finestra amb contingut de la pantalla" },
- { "ISO-8859-2", "Sprvce oken hbe s okrajem okna\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" },
- { "ISO-8859-1", "Vindueshndtering flytter dekorationsvindue istedet\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" },
- { "ISO-8859-1", "Vorschaubilder der Fenster mit dem Bildschirminhalt ausfllen" },
- { "iso-8859-7", " (-)" },
- { "iso-8859-1", "You've chosen to disable the startup hint.\nTo re-enable it, choose \"Startup Hint\"\nin the GNOME Control Centre" },
- { "iso-8859-1", "El aplique de reloj muestra en su panel la fecha y la hora de forma simple \ny ligero " },
- { "iso-8859-1", "Applet ei vasta salvestusksule.\nKas peaks ta niisama sulgema, vi veel ootama?" },
- { "iso-8859-1", "Lehio kudeatzaileak lehioaren dekorazaioa mugiarazten\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" },
- { "iso-8859-15", "Nyt sovellukset, joiden ikkunoista on nkyvill vain otsikkopalkki" },
- { "ISO-8859-1", "Afficher les tches qui ne sont pas dans la liste des fentres" },
- { "iso-8859-1", "Nl applet ag tabhair freagra ar iarratas sbhil.\nBain amach an applet n lean ar fnacht?" },
- { "iso-8859-1", "Amosa-las tarefas agochadas da lista de fiestras (SKIP-WINLIST)" },
- { "iso-8859-2", "Az ablakkezel a dekorcit mozgassa az ablak helyett\n(AfterStep, Enlightenment, FVWM, IceWM, SawMill)" },
- { "iso-8859-1", "Riempi la finestra delle anteprime con il contenuto dello schermo" },
- { "euc-jp", "ɥޥ͡Ͼꥦɥư\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" },
- { "euc-kr", "â ڰ ٹ â ̵\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" },
- { "iso-8859-13", "Priedas neatsakinja praym isisaugoti.\nPaalinti pried ar laukti toliau?" },
- { "iso-8859-1", "Window manager verplaatst dekoratie\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" },
- { "iso-8859-1", "Vindushndtereren flytter dekorasjonsvinduet i stedet\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" },
- { "iso-8859-2", "Przemieszczanie dekoracji zamiast okna\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" },
- { "iso-8859-1", "Este programa responsvel por executar outras aplicaes, embeber pequenos applets, a paz no mundo e crashes aleatrios do X." },
- { "iso-8859-1", "Mostrar tarefas que se escondem da lista de janelas (SKIP-WINLIST)" },
- { "koi8-r", " " },
- { "iso-8859-2", "Sprvca okien presva okraje okien\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" },
- { "iso-8859-2", "Kai posle, ki se skrivajo pred upravljalnik oken (SKIP-WINLIST)" },
- { "iso-8859-5", "Window a\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" },
- { "iso-8859-2", "Window menadzeri pomera dekoracioni prozor umesto toga\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" },
- { "iso-8859-1", "Fnsterhanteraren flyttar dekorationsfnstret istllet\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" },
- /*{ "TSCII", "츼- ¡ 츼 (츼--Ţ)" },*/
- { "iso-8859-9", "Kaydetme isteine bir uygulak cevap vermiyor .\nUygula sileyim mi , yoksa bekleyeyim mi ?" },
- { "koi8-u", "ͦ æ ͦ צ\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" },
- { "iso-8859-1", "Cwand on scriftr est bodj fo, li scriftr t totes\nles apliketes dvins sont pierdowes. Bodj ci scriftr chal?" },
- { "gb2312", "ǨƵװδڹ(AfterStep, Enlightenment, FVWM, IceWM, SawMill)" },
- { "big5", "޲z̥uʸ˹\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" },
-};
diff --git a/camel/tests/lib/addresses.c b/camel/tests/lib/addresses.c
deleted file mode 100644
index a97ac5e4f9..0000000000
--- a/camel/tests/lib/addresses.c
+++ /dev/null
@@ -1,51 +0,0 @@
-
-#include "addresses.h"
-#include "camel-test.h"
-
-void
-test_address_compare(CamelInternetAddress *addr, CamelInternetAddress *addr2)
-{
- const char *r1, *r2, *a1, *a2;
- char *e1, *e2, *f1, *f2;
- int j;
-
- check(camel_address_length(CAMEL_ADDRESS(addr)) == camel_address_length(CAMEL_ADDRESS(addr2)));
- for (j=0;j<camel_address_length(CAMEL_ADDRESS(addr));j++) {
-
- check(camel_internet_address_get(addr, j, &r1, &a1) == TRUE);
- check(camel_internet_address_get(addr2, j, &r2, &a2) == TRUE);
-
- check(string_equal(r1, r2));
- check(strcmp(a1, a2) == 0);
- }
- check(camel_internet_address_get(addr, j, &r1, &a1) == FALSE);
- check(camel_internet_address_get(addr2, j, &r2, &a2) == FALSE);
-
- e1 = camel_address_encode(CAMEL_ADDRESS(addr));
- e2 = camel_address_encode(CAMEL_ADDRESS(addr2));
-
- if (camel_address_length(CAMEL_ADDRESS(addr)) == 0)
- check(e1 == NULL && e2 == NULL);
- else
- check(e1 != NULL && e2 != NULL);
-
- if (e1 != NULL) {
- check_msg(string_equal(e1, e2), "e1 = '%s' e2 = '%s'", e1, e2);
- test_free(e1);
- test_free(e2);
- }
-
- f1 = camel_address_format(CAMEL_ADDRESS(addr));
- f2 = camel_address_format(CAMEL_ADDRESS(addr2));
-
- if (camel_address_length(CAMEL_ADDRESS(addr)) == 0)
- check(f1 == NULL && f2 == NULL);
- else
- check(f1 != NULL && f2 != NULL);
-
- if (f1 != NULL) {
- check_msg(string_equal(f1, f2), "f1 = '%s' f2 = '%s'", f1, f2);
- test_free(f1);
- test_free(f2);
- }
-}
diff --git a/camel/tests/lib/addresses.h b/camel/tests/lib/addresses.h
deleted file mode 100644
index dc35a19f05..0000000000
--- a/camel/tests/lib/addresses.h
+++ /dev/null
@@ -1,5 +0,0 @@
-
-#include <camel/camel-internet-address.h>
-
-/* addresses.c */
-void test_address_compare(CamelInternetAddress *addr, CamelInternetAddress *addr2);
diff --git a/camel/tests/lib/camel-test.c b/camel/tests/lib/camel-test.c
deleted file mode 100644
index a61f949f0a..0000000000
--- a/camel/tests/lib/camel-test.c
+++ /dev/null
@@ -1,350 +0,0 @@
-
-#include "camel-test.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <signal.h>
-
-#ifdef ENABLE_THREADS
-#include <pthread.h>
-#include <unistd.h>
-#endif
-
-#ifdef ENABLE_THREADS
-/* well i dunno, doesn't seem to be in the headers but hte manpage mentions it */
-/* a nonportable checking mutex for glibc, not really needed, just validates
- the test harness really */
-# ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
-static pthread_mutex_t lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
-# else
-static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-# endif
-#define CAMEL_TEST_LOCK pthread_mutex_lock(&lock)
-#define CAMEL_TEST_UNLOCK pthread_mutex_unlock(&lock)
-#define CAMEL_TEST_ID (pthread_self())
-#else
-#define CAMEL_TEST_LOCK
-#define CAMEL_TEST_UNLOCK
-#define CAMEL_TEST_ID (0)
-#endif
-
-static int setup;
-static int ok;
-
-struct _stack {
- struct _stack *next;
- int fatal;
- char *what;
-};
-
-/* per-thread state */
-struct _state {
- char *test;
- int nonfatal;
- struct _stack *state;
-};
-
-static GHashTable *info_table;
-
-int camel_test_verbose;
-
-static void
-dump_action(int id, struct _state *s, void *d)
-{
- struct _stack *node;
-
-#ifdef ENABLE_THREADS
- printf("\nThread %d:\n", id);
-#endif
- node = s->state;
- if (node) {
- printf("Current action:\n");
- while (node) {
- printf("\t%s%s\n", node->fatal?"":"[nonfatal]", node->what);
- node = node->next;
- }
- }
- printf("\tTest: %s\n", s->test);
-}
-
-static void die(int sig)
-{
- static int indie = 0;
-
- if (!indie) {
- indie = 1;
- printf("\n\nReceived fatal signal %d\n", sig);
- g_hash_table_foreach(info_table, (GHFunc)dump_action, 0);
-
-#ifdef ENABLE_THREADS
- if (camel_test_verbose > 2) {
- printf("Attach debugger to pid %d to debug\n", getpid());
- sleep(1000);
- }
-#endif
- }
-
- _exit(1);
-}
-
-static struct _state *
-current_state(void)
-{
- struct _state *info;
-
- if (info_table == NULL)
- info_table = g_hash_table_new(0, 0);
-
- info = g_hash_table_lookup(info_table, (void *)CAMEL_TEST_ID);
- if (info == NULL) {
- info = g_malloc0(sizeof(*info));
- g_hash_table_insert(info_table, (void *)CAMEL_TEST_ID, info);
- }
- return info;
-}
-
-
-void camel_test_init(int argc, char **argv)
-{
- void camel_init(void);
- int i;
-
- setup = 1;
-
-#ifndef ENABLE_THREADS
- camel_init();
-#endif
-
- info_table = g_hash_table_new(0, 0);
-
- /* yeah, we do need ot thread init, even though camel isn't compiled with enable threads */
- g_thread_init(NULL);
-
- signal(SIGSEGV, die);
- signal(SIGABRT, die);
-
- /* default, just say what, how well we did, unless fail, then abort */
- camel_test_verbose = 1;
-
- for (i=0;i<argc;i++) {
- if (argv[i][0] == '-') {
- switch (argv[i][1]) {
- case 'v':
- camel_test_verbose = strlen(argv[i]);
- break;
- case 'q':
- camel_test_verbose = 0;
- break;
- }
- }
- }
-}
-
-void camel_test_start(const char *what)
-{
- struct _state *s;
-
- CAMEL_TEST_LOCK;
-
- s = current_state();
-
- if (!setup)
- camel_test_init(0, 0);
-
- ok = 1;
-
- s->test = g_strdup(what);
-
- if (camel_test_verbose > 0) {
- printf("Test: %s ... ", what);
- fflush(stdout);
- }
-
- CAMEL_TEST_UNLOCK;
-}
-
-void camel_test_push(const char *what, ...)
-{
- struct _stack *node;
- va_list ap;
- char *text;
- struct _state *s;
-
- CAMEL_TEST_LOCK;
-
- s = current_state();
-
- va_start(ap, what);
- text = g_strdup_vprintf(what, ap);
- va_end(ap);
-
- if (camel_test_verbose > 3)
- printf("Start step: %s\n", text);
-
- node = g_malloc(sizeof(*node));
- node->what = text;
- node->next = s->state;
- node->fatal = 1;
- s->state = node;
-
- CAMEL_TEST_UNLOCK;
-}
-
-void camel_test_pull(void)
-{
- struct _stack *node;
- struct _state *s;
-
- CAMEL_TEST_LOCK;
-
- s = current_state();
-
- g_assert(s->state);
-
- if (camel_test_verbose > 3)
- printf("Finish step: %s\n", s->state->what);
-
- node = s->state;
- s->state = node->next;
- if (!node->fatal)
- s->nonfatal--;
- g_free(node->what);
- g_free(node);
-
- CAMEL_TEST_UNLOCK;
-}
-
-/* where to set breakpoints */
-void camel_test_break(void);
-
-void camel_test_break(void)
-{
-}
-
-void camel_test_fail(const char *why, ...)
-{
- va_list ap;
-
- va_start(ap, why);
- camel_test_failv(why, ap);
- va_end(ap);
-}
-
-
-void camel_test_failv(const char *why, va_list ap)
-{
- char *text;
- struct _state *s;
-
- CAMEL_TEST_LOCK;
-
- s = current_state();
-
- text = g_strdup_vprintf(why, ap);
-
- if ((s->nonfatal == 0 && camel_test_verbose > 0)
- || (s->nonfatal && camel_test_verbose > 1)) {
- printf("Failed.\n%s\n", text);
- camel_test_break();
- }
-
- g_free(text);
-
- if ((s->nonfatal == 0 && camel_test_verbose > 0)
- || (s->nonfatal && camel_test_verbose > 2)) {
- g_hash_table_foreach(info_table, (GHFunc)dump_action, 0);
- }
-
- if (s->nonfatal == 0) {
- exit(1);
- } else {
- ok=0;
- if (camel_test_verbose > 1) {
- printf("Known problem (ignored):\n");
- dump_action(CAMEL_TEST_ID, s, 0);
- }
- }
-
- CAMEL_TEST_UNLOCK;
-}
-
-void camel_test_nonfatal(const char *what, ...)
-{
- struct _stack *node;
- va_list ap;
- char *text;
- struct _state *s;
-
- CAMEL_TEST_LOCK;
-
- s = current_state();
-
- va_start(ap, what);
- text = g_strdup_vprintf(what, ap);
- va_end(ap);
-
- if (camel_test_verbose > 3)
- printf("Start nonfatal: %s\n", text);
-
- node = g_malloc(sizeof(*node));
- node->what = text;
- node->next = s->state;
- node->fatal = 0;
- s->nonfatal++;
- s->state = node;
-
- CAMEL_TEST_UNLOCK;
-}
-
-void camel_test_fatal(void)
-{
- camel_test_pull();
-}
-
-void camel_test_end(void)
-{
- if (camel_test_verbose > 0) {
- if (ok)
- printf("Ok\n");
- else
- printf("Partial success\n");
- }
-
- fflush(stdout);
-}
-
-
-
-
-/* compare strings, ignore whitespace though */
-int string_equal(const char *a, const char *b)
-{
- const char *ap, *bp;
-
- ap = a;
- bp = b;
-
- while (*ap && *bp) {
- while (*ap == ' ' || *ap == '\n' || *ap == '\t')
- ap++;
- while (*bp == ' ' || *bp == '\n' || *bp == '\t')
- bp++;
-
- a = ap;
- b = bp;
-
- while (*ap && *ap != ' ' && *ap != '\n' && *ap != '\t')
- ap++;
- while (*bp && *bp != ' ' && *bp != '\n' && *bp != '\t')
- bp++;
-
- if (ap - a != bp - a
- && ap - 1 > 0
- && memcmp(a, b, ap-a) != 0) {
- return 0;
- }
- }
-
- return 1;
-}
-
diff --git a/camel/tests/lib/camel-test.h b/camel/tests/lib/camel-test.h
deleted file mode 100644
index 986a943fa3..0000000000
--- a/camel/tests/lib/camel-test.h
+++ /dev/null
@@ -1,68 +0,0 @@
-
-/* some utilities for testing */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <glib.h>
-
-void camel_test_failv(const char *why, va_list ap);
-
-/* perform a check assertion */
-#define check(x) do {if (!(x)) { camel_test_fail("%s:%d: %s", __FILE__, __LINE__, #x); } } while (0)
-/* check with message */
-#ifdef __GNUC__
-#define check_msg(x, y, z...) do {if (!(x)) { camel_test_fail("%s:%d: %s\n\t" #y, __FILE__, __LINE__, #x, ##z); } } while (0)
-#else
-static void check_msg(int truth, char *fmt, ...)
-{
- /* no gcc, we lose the condition that failed, nm */
- if (!truth) {
- va_list ap;
- va_start(ap, fmt);
- camel_test_failv(fmt, ap);
- va_end(ap);
- }
-}
-#endif
-
-#define check_count(object, expected) do { \
- if (CAMEL_OBJECT(object)->ref_count != expected) { \
- camel_test_fail("%s->ref_count != %s\n\tref_count = %d", #object, #expected, CAMEL_OBJECT(object)->ref_count); \
- } \
-} while (0)
-
-#define check_unref(object, expected) do { \
- check_count(object, expected); \
- camel_object_unref(CAMEL_OBJECT(object)); \
- if (expected == 1) { \
- object = NULL; \
- } \
-} while (0)
-
-#define test_free(mem) (g_free(mem), mem=NULL)
-
-#define push camel_test_push
-#define pull camel_test_pull
-
-void camel_test_init(int argc, char **argv);
-
-/* start/finish a new test */
-void camel_test_start(const char *what);
-void camel_test_end(void);
-
-/* start/finish a new test part */
-void camel_test_push(const char *what, ...);
-void camel_test_pull(void);
-
-/* fail a test, with a reason why */
-void camel_test_fail(const char *why, ...);
-void camel_test_failv(const char *why, va_list ap);
-
-/* Set whether a failed test quits. May be nested, but must be called in nonfatal/fatal pairs */
-void camel_test_nonfatal(const char *why, ...);
-void camel_test_fatal(void);
-
-/* utility functions */
-/* compare strings, ignore whitespace though */
-int string_equal(const char *a, const char *b);
diff --git a/camel/tests/lib/folders.c b/camel/tests/lib/folders.c
deleted file mode 100644
index ba02001bcc..0000000000
--- a/camel/tests/lib/folders.c
+++ /dev/null
@@ -1,526 +0,0 @@
-#include <string.h>
-
-#include "camel-test.h"
-#include "folders.h"
-#include "messages.h"
-
-#include "camel/camel-exception.h"
-
-/* check the total/unread is what we think it should be */
-void
-test_folder_counts(CamelFolder *folder, int total, int unread)
-{
- GPtrArray *s;
- int i, myunread;
- CamelMessageInfo *info;
-
- push("test folder counts %d total %d unread", total, unread);
-
- /* first, use the standard functions */
- check(camel_folder_get_message_count(folder) == total);
- check(camel_folder_get_unread_message_count(folder) == total);
-
- /* next, use the summary */
- s = camel_folder_get_summary(folder);
- check(s != NULL);
- check(s->len == total);
- myunread = s->len;
- for (i=0;i<s->len;i++) {
- info = s->pdata[i];
- if (info->flags & CAMEL_MESSAGE_SEEN)
- myunread--;
- }
- check(unread == myunread);
- camel_folder_free_summary(folder, s);
-
- /* last, use the uid list */
- s = camel_folder_get_uids(folder);
- check(s != NULL);
- check(s->len == total);
- myunread = s->len;
- for (i=0;i<s->len;i++) {
- info = camel_folder_get_message_info(folder, s->pdata[i]);
- if (info->flags & CAMEL_MESSAGE_SEEN)
- myunread--;
- camel_folder_free_message_info(folder, info);
- }
- check(unread == myunread);
- camel_folder_free_uids(folder, s);
-
- pull();
-}
-
-static int
-safe_strcmp(const char *a, const char *b)
-{
- if (a == NULL && b == NULL)
- return 0;
- if (a == NULL)
- return 1;
- if (b == NULL)
- return -1;
- return strcmp(a, b);
-}
-
-void
-test_message_info(CamelMimeMessage *msg, const CamelMessageInfo *info)
-{
- check_msg(safe_strcmp(camel_message_info_subject(info), camel_mime_message_get_subject(msg)) == 0,
- "info->subject = '%s', get_subject() = '%s'", camel_message_info_subject(info), camel_mime_message_get_subject(msg));
-
- /* FIXME: testing from/cc/to, etc is more tricky */
-
- check(info->date_sent == camel_mime_message_get_date(msg, NULL));
-
- /* date received isn't set for messages that haven't been sent anywhere ... */
- /*check(info->date_received == camel_mime_message_get_date_received(msg, NULL));*/
-
- /* so is messageid/references, etc */
-}
-
-/* check a message is present */
-void
-test_folder_message(CamelFolder *folder, const char *uid)
-{
- CamelMimeMessage *msg;
- CamelMessageInfo *info;
- GPtrArray *s;
- int i;
- CamelException *ex = camel_exception_new();
- int found;
-
- push("uid %s is in folder", uid);
-
- /* first try getting info */
- info = camel_folder_get_message_info(folder, uid);
- check(info != NULL);
- check(strcmp(camel_message_info_uid(info), uid) == 0);
- camel_folder_free_message_info(folder, info);
-
- /* then, getting message */
- msg = camel_folder_get_message(folder, uid, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- check(msg != NULL);
-
- /* cross check with info */
- test_message_info(msg, info);
-
- camel_object_unref((CamelObject *)msg);
-
- /* see if it is in the summary (only once) */
- s = camel_folder_get_summary(folder);
- check(s != NULL);
- found = 0;
- for (i=0;i<s->len;i++) {
- info = s->pdata[i];
- if (strcmp(camel_message_info_uid(info), uid) == 0)
- found++;
- }
- check(found == 1);
- camel_folder_free_summary(folder, s);
-
- /* check it is in the uid list */
- s = camel_folder_get_uids(folder);
- check(s != NULL);
- found = 0;
- for (i=0;i<s->len;i++) {
- if (strcmp(s->pdata[i], uid) == 0)
- found++;
- }
- check(found == 1);
- camel_folder_free_uids(folder, s);
-
- camel_exception_free(ex);
-
- pull();
-}
-
-/* check message not present */
-void
-test_folder_not_message(CamelFolder *folder, const char *uid)
-{
- CamelMimeMessage *msg;
- CamelMessageInfo *info;
- GPtrArray *s;
- int i;
- CamelException *ex = camel_exception_new();
- int found;
-
- push("uid %s is not in folder", uid);
-
- /* first try getting info */
- info = camel_folder_get_message_info(folder, uid);
- check(info == NULL);
-
- /* then, getting message */
- msg = camel_folder_get_message(folder, uid, ex);
- check(camel_exception_is_set(ex));
- check(msg == NULL);
- camel_exception_clear(ex);
-
- /* see if it is not in the summary (only once) */
- s = camel_folder_get_summary(folder);
- check(s != NULL);
- found = 0;
- for (i=0;i<s->len;i++) {
- info = s->pdata[i];
- if (strcmp(camel_message_info_uid(info), uid) == 0)
- found++;
- }
- check(found == 0);
- camel_folder_free_summary(folder, s);
-
- /* check it is not in the uid list */
- s = camel_folder_get_uids(folder);
- check(s != NULL);
- found = 0;
- for (i=0;i<s->len;i++) {
- if (strcmp(s->pdata[i], uid) == 0)
- found++;
- }
- check(found == 0);
- camel_folder_free_uids(folder, s);
-
- camel_exception_free(ex);
-
- pull();
-}
-
-/* test basic store operations on folders */
-/* TODO: Add subscription stuff */
-void
-test_folder_basic(CamelSession *session, const char *storename, int local)
-{
- CamelStore *store;
- CamelException *ex = camel_exception_new();
- CamelFolder *folder, *root;
- char *what = g_strdup_printf("testing store: %s", storename);
-
- camel_test_start(what);
- test_free(what);
-
- push("getting store");
- store = camel_session_get_store(session, storename, ex);
- check_msg(!camel_exception_is_set(ex), "getting store: %s", camel_exception_get_description(ex));
- check(store != NULL);
- pull();
-
- /* local providers == no root folder */
- push("getting root folder");
- root = camel_store_get_root_folder(store, ex);
- if (local) {
- check(camel_exception_is_set(ex));
- check(root == NULL);
- camel_exception_clear(ex);
- } else {
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- check(root != NULL);
- check_unref(root, 1);
- }
- pull();
-
- /* same for default folder */
- push("getting default folder");
- root = camel_store_get_root_folder(store, ex);
- if (local) {
- check(camel_exception_is_set(ex));
- check(root == NULL);
- camel_exception_clear(ex);
- } else {
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- check(root != NULL);
- check_unref(root, 1);
- }
- pull();
-
- push("getting a non-existant folder, no create");
- folder = camel_store_get_folder(store, "unknown", 0, ex);
- check(camel_exception_is_set(ex));
- check(folder == NULL);
- camel_exception_clear(ex);
- pull();
-
- push("getting a non-existant folder, with create");
- folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- check(folder != NULL);
- check_unref(folder, 1);
- pull();
-
- push("getting an existing folder");
- folder = camel_store_get_folder(store, "testbox", 0, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- check(folder != NULL);
- check_unref(folder, 1);
- pull();
-
- push("renaming a non-existant folder");
- camel_store_rename_folder(store, "unknown1", "unknown2", ex);
- check(camel_exception_is_set(ex));
- camel_exception_clear(ex);
- pull();
-
- push("renaming an existing folder");
- camel_store_rename_folder(store, "testbox", "testbox2", ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- pull();
-
- push("opening the old name of a renamed folder");
- folder = camel_store_get_folder(store, "testbox", 0, ex);
- check(camel_exception_is_set(ex));
- check(folder == NULL);
- camel_exception_clear(ex);
- pull();
-
- push("opening the new name of a renamed folder");
- folder = camel_store_get_folder(store, "testbox2", 0, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- check(folder != NULL);
- check_unref(folder, 1);
- pull();
-
- push("deleting a non-existant folder");
- camel_store_delete_folder(store, "unknown", ex);
- check(camel_exception_is_set(ex));
- camel_exception_clear(ex);
- pull();
-
- push("deleting an existing folder");
- camel_store_delete_folder(store, "testbox2", ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- pull();
-
- push("opening a folder that has been deleted");
- folder = camel_store_get_folder(store, "testbox2", 0, ex);
- check(camel_exception_is_set(ex));
- check(folder == NULL);
- camel_exception_clear(ex);
- pull();
-
- check_unref(store, 1);
-
- camel_test_end();
-
- camel_exception_free(ex);
-}
-
-
-/* todo: cross-check everything with folder_info checks as well */
-/* this should probably take a folder instead of a session ... */
-void
-test_folder_message_ops(CamelSession *session, const char *name, int local)
-{
- CamelStore *store;
- CamelException *ex = camel_exception_new();
- CamelFolder *folder;
- CamelMimeMessage *msg;
- int j;
- int indexed, max;
- GPtrArray *uids;
- CamelMessageInfo *info;
-
- max=local?2:1;
-
- for (indexed = 0;indexed<max;indexed++) {
- char *what = g_strdup_printf("folder ops: %s %s", name, local?(indexed?"indexed":"non-indexed"):"");
- int flags;
-
- camel_test_start(what);
- test_free(what);
-
- push("getting store");
- store = camel_session_get_store(session, name, ex);
- check_msg(!camel_exception_is_set(ex), "getting store: %s", camel_exception_get_description(ex));
- check(store != NULL);
- pull();
-
- push("creating %sindexed folder", indexed?"":"non-");
- if (indexed)
- flags = CAMEL_STORE_FOLDER_CREATE|CAMEL_STORE_FOLDER_BODY_INDEX;
- else
- flags = CAMEL_STORE_FOLDER_CREATE;
- folder = camel_store_get_folder(store, "testbox", flags, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- check(folder != NULL);
-
- /* verify empty/can't get nonexistant stuff */
- test_folder_counts(folder, 0, 0);
- test_folder_not_message(folder, "0");
- test_folder_not_message(folder, "");
-
- for (j=0;j<10;j++) {
- char *content, *subject;
-
- push("creating test message");
- msg = test_message_create_simple();
- content = g_strdup_printf("Test message %d contents\n\n", j);
- test_message_set_content_simple((CamelMimePart *)msg, 0, "text/plain",
- content, strlen(content));
- test_free(content);
- subject = g_strdup_printf("Test message %d", j);
- camel_mime_message_set_subject(msg, subject);
- pull();
-
- push("appending simple message %d", j);
- camel_folder_append_message(folder, msg, NULL, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
-
- /* sigh, this shouldn't be required, but the imap code is too dumb to do it itself */
- if (!local) {
- push("forcing a refresh of folder updates");
- camel_folder_refresh_info(folder, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- pull();
- }
-
- if (!local)
- camel_test_nonfatal("unread counts dont seem right for imap");
-
- test_folder_counts(folder, j+1, j+1);
-
- if (!local)
- camel_test_fatal();
-
- push("checking it is in the right uid slot & exists");
- uids = camel_folder_get_uids(folder);
- check(uids != NULL);
- check(uids->len == j+1);
- test_folder_message(folder, uids->pdata[j]);
- pull();
-
- push("checking it is the right message (subject): %s", subject);
- info = camel_folder_get_message_info(folder, uids->pdata[j]);
- check_msg(strcmp(camel_message_info_subject(info), subject)==0,
- "info->subject %s", camel_message_info_subject(info));
- camel_folder_free_uids(folder, uids);
- camel_folder_free_message_info(folder, info);
- pull();
-
- test_free(subject);
-
- check_unref(msg, 1);
- pull();
- }
-
- check_unref(folder, 1);
- pull();
-
- push("deleting test folder, with messages in it");
- camel_store_delete_folder(store, "testbox", ex);
- check(camel_exception_is_set(ex));
- camel_exception_clear(ex);
- pull();
-
- push("re-opening folder");
- folder = camel_store_get_folder(store, "testbox", flags, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- check(folder != NULL);
-
- /* verify counts */
- test_folder_counts(folder, 10, 10);
-
- /* re-check uid's, after a reload */
- uids = camel_folder_get_uids(folder);
- check(uids != NULL);
- check(uids->len == 10);
- for (j=0;j<10;j++) {
- char *subject = g_strdup_printf("Test message %d", j);
-
- push("verify reload of %s", subject);
- test_folder_message(folder, uids->pdata[j]);
-
- info = camel_folder_get_message_info(folder, uids->pdata[j]);
- check_msg(strcmp(camel_message_info_subject(info), subject)==0,
- "info->subject %s", camel_message_info_subject(info));
- test_free(subject);
- camel_folder_free_message_info(folder, info);
- pull();
- }
-
- push("deleting first message & expunging");
- camel_folder_delete_message(folder, uids->pdata[0]);
- test_folder_counts(folder, 10, 10);
- camel_folder_expunge(folder, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- test_folder_not_message(folder, uids->pdata[0]);
- test_folder_counts(folder, 9, 9);
-
- camel_folder_free_uids(folder, uids);
-
- uids = camel_folder_get_uids(folder);
- check(uids != NULL);
- check(uids->len == 9);
- for (j=0;j<9;j++) {
- char *subject = g_strdup_printf("Test message %d", j+1);
-
- push("verify after expunge of %s", subject);
- test_folder_message(folder, uids->pdata[j]);
-
- info = camel_folder_get_message_info(folder, uids->pdata[j]);
- check_msg(strcmp(camel_message_info_subject(info), subject)==0,
- "info->subject %s", camel_message_info_subject(info));
- test_free(subject);
- camel_folder_free_message_info(folder, info);
- pull();
- }
- pull();
-
- push("deleting last message & expunging");
- camel_folder_delete_message(folder, uids->pdata[8]);
- /* sync? */
- test_folder_counts(folder, 9, 9);
- camel_folder_expunge(folder, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- test_folder_not_message(folder, uids->pdata[8]);
- test_folder_counts(folder, 8, 8);
-
- camel_folder_free_uids(folder, uids);
-
- uids = camel_folder_get_uids(folder);
- check(uids != NULL);
- check(uids->len == 8);
- for (j=0;j<8;j++) {
- char *subject = g_strdup_printf("Test message %d", j+1);
-
- push("verify after expunge of %s", subject);
- test_folder_message(folder, uids->pdata[j]);
-
- info = camel_folder_get_message_info(folder, uids->pdata[j]);
- check_msg(strcmp(camel_message_info_subject(info), subject)==0,
- "info->subject %s", camel_message_info_subject(info));
- test_free(subject);
- camel_folder_free_message_info(folder, info);
- pull();
- }
- pull();
-
- push("deleting all messages & expunging");
- for (j=0;j<8;j++) {
- camel_folder_delete_message(folder, uids->pdata[j]);
- }
- /* sync? */
- test_folder_counts(folder, 8, 8);
- camel_folder_expunge(folder, ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- for (j=0;j<8;j++) {
- test_folder_not_message(folder, uids->pdata[j]);
- }
- test_folder_counts(folder, 0, 0);
-
- camel_folder_free_uids(folder, uids);
- pull();
-
- check_unref(folder, 1);
- pull(); /* re-opening folder */
-
- push("deleting test folder, with no messages in it");
- camel_store_delete_folder(store, "testbox", ex);
- check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex));
- pull();
-
- check_unref(store, 1);
- camel_test_end();
- }
-
- camel_exception_free(ex);
-}
diff --git a/camel/tests/lib/folders.h b/camel/tests/lib/folders.h
deleted file mode 100644
index 2cb2d97028..0000000000
--- a/camel/tests/lib/folders.h
+++ /dev/null
@@ -1,20 +0,0 @@
-
-#include "camel/camel-session.h"
-#include "camel/camel-store.h"
-
-#include <camel/camel-folder.h>
-#include <camel/camel-folder-summary.h>
-#include <camel/camel-mime-message.h>
-
-/* check the total/unread is what we think it should be, everywhere it can be determined */
-void test_folder_counts(CamelFolder *folder, int total, int unread);
-/* cross-check info/msg */
-void test_message_info(CamelMimeMessage *msg, const CamelMessageInfo *info);
-/* check a message is present everywhere it should be */
-void test_folder_message(CamelFolder *folder, const char *uid);
-/* check message not present everywhere it shouldn't be */
-void test_folder_not_message(CamelFolder *folder, const char *uid);
-/* test basic folder ops on a store */
-void test_folder_basic(CamelSession *session, const char *storename, int local);
-/* test basic message operations on a folder */
-void test_folder_message_ops(CamelSession *session, const char *storename, int local);
diff --git a/camel/tests/lib/messages.c b/camel/tests/lib/messages.c
deleted file mode 100644
index a8c8b30465..0000000000
--- a/camel/tests/lib/messages.c
+++ /dev/null
@@ -1,153 +0,0 @@
-#include <string.h>
-
-#include "messages.h"
-#include "camel-test.h"
-
-#include <camel/camel-mime-message.h>
-#include <camel/camel-stream-fs.h>
-#include <camel/camel-stream-mem.h>
-
-CamelMimeMessage *
-test_message_create_simple(void)
-{
- CamelMimeMessage *msg;
- CamelInternetAddress *addr;
-
- msg = camel_mime_message_new();
-
- addr = camel_internet_address_new();
- camel_internet_address_add(addr, "Michael Zucchi", "zed@nowhere.com");
- camel_mime_message_set_from(msg, addr);
- camel_address_remove((CamelAddress *)addr, -1);
- camel_internet_address_add(addr, "POSTMASTER", "POSTMASTER@somewhere.net");
- camel_mime_message_set_recipients(msg, CAMEL_RECIPIENT_TYPE_TO, addr);
- camel_address_remove((CamelAddress *)addr, -1);
- camel_internet_address_add(addr, "Michael Zucchi", "zed@nowhere.com");
- camel_mime_message_set_recipients(msg, CAMEL_RECIPIENT_TYPE_CC, addr);
-
- check_unref(addr, 1);
-
- camel_mime_message_set_subject(msg, "Simple message subject");
- camel_mime_message_set_date(msg, time(0), 930);
-
- return msg;
-}
-
-static void
-content_finalise(CamelObject *folder, void *crap, void *ba)
-{
- g_byte_array_free(ba, TRUE);
-}
-
-void
-test_message_set_content_simple(CamelMimePart *part, int how, const char *type, const char *text, int len)
-{
- CamelStreamMem *content = NULL;
- CamelDataWrapper *dw;
- static GByteArray *ba;
-
- switch (how) {
- case 0:
- camel_mime_part_set_content(part, text, len, type);
- break;
- case 1:
- content = (CamelStreamMem *)camel_stream_mem_new_with_buffer(text, len);
- break;
- case 2:
- content = (CamelStreamMem *)camel_stream_mem_new();
- camel_stream_mem_set_buffer(content, text, len);
- break;
- case 3:
- ba = g_byte_array_new();
- g_byte_array_append(ba, text, len);
-
- content = (CamelStreamMem *)camel_stream_mem_new_with_byte_array(ba);
- ba = NULL;
- break;
- case 4:
- ba = g_byte_array_new();
- g_byte_array_append(ba, text, len);
-
- content = (CamelStreamMem *)camel_stream_mem_new();
- camel_stream_mem_set_byte_array(content, ba);
-
- camel_object_hook_event((CamelObject *)content, "finalize", content_finalise, ba);
- break;
- }
-
- if (content != 0) {
- dw = camel_data_wrapper_new();
- camel_data_wrapper_set_mime_type (dw, type);
-
- camel_data_wrapper_construct_from_stream(dw, (CamelStream *)content);
- camel_medium_set_content_object((CamelMedium *)part, dw);
-
- check_unref(content, 2);
- check_unref(dw, 2);
- }
-}
-
-int
-test_message_write_file(CamelMimeMessage *msg, const char *name)
-{
- CamelStreamFs *file;
- int ret;
-
- file = (CamelStreamFs *)camel_stream_fs_new_with_name(name, O_CREAT|O_WRONLY, 0600);
- camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, (CamelStream *)file);
- ret = camel_stream_close((CamelStream *)file);
-
- check(((CamelObject *)file)->ref_count == 1);
- camel_object_unref((CamelObject *)file);
-
- return ret;
-}
-
-CamelMimeMessage *
-test_message_read_file(const char *name)
-{
- CamelStreamFs *file;
- CamelMimeMessage *msg2;
-
- file = (CamelStreamFs *)camel_stream_fs_new_with_name(name, O_RDONLY, 0);
- msg2 = camel_mime_message_new();
-
- camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg2, (CamelStream *)file);
- /* file's refcount may be > 1 if the message is real big */
- check(CAMEL_OBJECT(file)->ref_count >=1);
-
- return msg2;
-}
-
-int
-test_message_compare_content(CamelDataWrapper *dw, const char *text, int len)
-{
- CamelStreamMem *content;
-
- /* sigh, ok, so i len == 0, dw will probably be 0 too
- camel_mime_part_set_content is weird like that */
- if (dw == 0 && len == 0)
- return 0;
-
- content = (CamelStreamMem *)camel_stream_mem_new();
- camel_data_wrapper_write_to_stream(dw, (CamelStream *)content);
-
- check_msg(content->buffer->len == len, "buffer->len = %d, len = %d", content->buffer->len, len);
- check_msg(memcmp(content->buffer->data, text, content->buffer->len) == 0, "len = %d", len);
-
- check_unref(content, 1);
-
- return 0;
-}
-
-int
-test_message_compare_header(CamelMimeMessage *m1, CamelMimeMessage *m2)
-{
- return 0;
-}
-
-int
-test_message_compare_messages(CamelMimeMessage *m1, CamelMimeMessage *m2)
-{
- return 0;
-}
diff --git a/camel/tests/lib/messages.h b/camel/tests/lib/messages.h
deleted file mode 100644
index 9cb5758826..0000000000
--- a/camel/tests/lib/messages.h
+++ /dev/null
@@ -1,12 +0,0 @@
-
-#include <camel/camel-mime-message.h>
-
-/* how many ways to set the content contents */
-#define SET_CONTENT_WAYS (5)
-
-/* messages.c */
-CamelMimeMessage *test_message_create_simple(void);
-void test_message_set_content_simple(CamelMimePart *part, int how, const char *type, const char *text, int len);
-int test_message_write_file(CamelMimeMessage *msg, const char *name);
-CamelMimeMessage *test_message_read_file(const char *name);
-int test_message_compare_content(CamelDataWrapper *dw, const char *text, int len);
diff --git a/camel/tests/lib/streams.c b/camel/tests/lib/streams.c
deleted file mode 100644
index e4dc006363..0000000000
--- a/camel/tests/lib/streams.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- stream tests
-
- todo: do we need a seek test that seeks beyond the eos, writes,
- then reads and checks for 0's in the space?
-*/
-
-#include <string.h>
-
-#include "camel/camel-stream.h"
-#include "camel/camel-seekable-stream.h"
-#include "camel/camel-seekable-substream.h"
-
-#include "streams.h"
-
-#include "camel-test.h"
-
-static char teststring[] = "\xaa\x55\xc0\x0c\xff\x00";
-static char testbuf[10240];
-
-/* pass in an empty read/write stream */
-void
-test_stream_seekable_writepart(CamelSeekableStream *s)
-{
- off_t end;
- int i;
-
- push("seekable stream test, writing ");
-
- check(camel_seekable_stream_tell(s) == 0);
- check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_SET) == 0);
- check(camel_seekable_stream_tell(s) == 0);
-
- check(camel_stream_write(CAMEL_STREAM(s), "", 0) == 0);
- check(camel_seekable_stream_tell(s) == 0);
- check(camel_stream_write(CAMEL_STREAM(s), "\n", 1) == 1);
- check(camel_seekable_stream_tell(s) == 1);
-
- for (i=0;i<10240;i++) {
- check(camel_stream_write(CAMEL_STREAM(s), teststring, sizeof(teststring)) == sizeof(teststring));
- check(camel_seekable_stream_tell(s) == 1 + (i+1)*sizeof(teststring));
- }
- end = 10240*sizeof(teststring)+1;
-
- check_msg(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_END) == end, "seek =%d end = %d",
- camel_seekable_stream_seek(s, 0, CAMEL_STREAM_END), end);
-
- check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_END) == end);
- check(camel_seekable_stream_tell(s) == end);
- /* need to read 0 first to set eos */
- check(camel_stream_read(CAMEL_STREAM(s), testbuf, 10240) == 0);
- check(camel_stream_eos(CAMEL_STREAM(s)));
-
- pull();
-}
-
-void
-test_stream_seekable_readpart(CamelSeekableStream *s)
-{
- off_t off, new, end;
- int i, j;
-
- push("seekable stream test, re-reading");
-
- end = 10240*sizeof(teststring)+1;
-
- check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_SET) == 0);
- check(camel_seekable_stream_tell(s) == 0);
- check(!camel_stream_eos(CAMEL_STREAM(s)));
-
- off = 0;
- for (i=0;i<1024;i++) {
-
- new = i*3;
-
- /* exercise all seek methods */
- switch(i % 3) {
- case 0:
- check(camel_seekable_stream_seek(s, new, CAMEL_STREAM_SET) == new);
- break;
- case 1:
- check(camel_seekable_stream_seek(s, new-off, CAMEL_STREAM_CUR) == new);
- break;
- case 2:
- check(camel_seekable_stream_seek(s, new-end, CAMEL_STREAM_END) == new);
- break;
- }
- check(camel_seekable_stream_tell(s) == new);
-
- check(camel_stream_read(CAMEL_STREAM(s), testbuf, i*3) == i*3);
- for (j=0;j<i*3;j++) {
- int k = new + j;
-
- if (k==0) {
- check(testbuf[j] == '\n');
- } else {
- check(testbuf[j] == teststring[(k-1) % sizeof(teststring)]);
- }
- }
- off = new+i*3;
- }
-
- /* verify end-of-file behaviour */
- check(camel_seekable_stream_seek(s, -1, CAMEL_STREAM_END) == end-1);
- check(camel_seekable_stream_tell(s) == end-1);
-
- check(camel_stream_read(CAMEL_STREAM(s), testbuf, 10240) == 1);
- check(testbuf[0] == teststring[sizeof(teststring)-1]);
-
- check(camel_stream_read(CAMEL_STREAM(s), testbuf, 10240) == 0);
- check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_CUR) == end);
- check(camel_seekable_stream_tell(s) == end);
- check(camel_stream_eos(CAMEL_STREAM(s)));
-
- pull();
-}
-
-/*
- 0 = write to the substream
- 1 = write to the parent stream at the right spot
-*/
-void
-test_seekable_substream_writepart(CamelStream *s, int type)
-{
- CamelSeekableStream *ss = (CamelSeekableStream *)s;
- CamelSeekableSubstream *sus = (CamelSeekableSubstream *)s;
- CamelSeekableStream *sp = sus->parent_stream;
- int i, len;
- off_t end;
-
- push("writing substream, type %d", type);
-
- if (type == 1) {
- check(camel_seekable_stream_seek(sp, ss->bound_start, CAMEL_STREAM_SET) == ss->bound_start);
- s = (CamelStream *)sp;
- } else {
- check(camel_seekable_stream_tell(ss) == ss->bound_start);
- check(camel_seekable_stream_seek(ss, 0, CAMEL_STREAM_SET) == ss->bound_start);
- }
-
- check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_start);
-
- check(camel_stream_write(s, "", 0) == 0);
- check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_start);
-
- /* fill up the bounds with writes */
- if (ss->bound_end != CAMEL_STREAM_UNBOUND) {
- for (i=0;i<(ss->bound_end-ss->bound_start)/sizeof(teststring);i++) {
- check(camel_stream_write(s, teststring, sizeof(teststring)) == sizeof(teststring));
- check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_start + (i+1)*sizeof(teststring));
- }
- len = (ss->bound_end-ss->bound_start) % sizeof(teststring);
- check(camel_stream_write(s, teststring, len) == len);
- check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_end);
- if (type == 0) {
- check(camel_stream_write(s, teststring, sizeof(teststring)) == 0);
- check(camel_stream_eos(s));
- check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_end);
- }
- } else {
- /* just 10K */
- for (i=0;i<10240;i++) {
- check(camel_stream_write(CAMEL_STREAM(s), teststring, sizeof(teststring)) == sizeof(teststring));
- check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_start + (i+1)*sizeof(teststring));
- }
-
- /* we can't really verify any end length here */
- }
-
- pull();
-}
-
-void
-test_seekable_substream_readpart(CamelStream *s)
-{
- CamelSeekableStream *ss = (CamelSeekableStream *)s;
- CamelSeekableSubstream *sus = (CamelSeekableSubstream *)s;
- CamelSeekableStream *sp = sus->parent_stream;
- int i, len;
- off_t end;
-
- push("reading substream");
-
- check(camel_seekable_stream_seek(ss, 0, CAMEL_STREAM_SET) == ss->bound_start);
- check(camel_seekable_stream_tell(ss) == ss->bound_start);
-
- check(camel_seekable_stream_seek(sp, ss->bound_start, CAMEL_STREAM_SET) == ss->bound_start);
- check(camel_seekable_stream_tell(sp) == ss->bound_start);
-
- /* check writes, cross check with parent stream */
- if (ss->bound_end != CAMEL_STREAM_UNBOUND) {
- for (i=0;i<(ss->bound_end-ss->bound_start)/sizeof(teststring);i++) {
- check(camel_stream_read(s, testbuf, sizeof(teststring)) == sizeof(teststring));
- check(memcmp(testbuf, teststring, sizeof(teststring)) == 0);
- check(camel_seekable_stream_tell(ss) == ss->bound_start + (i+1)*sizeof(teststring));
-
- /* yeah great, the substreams affect the seek ... */
- check(camel_seekable_stream_seek(sp, ss->bound_start + (i)*sizeof(teststring), CAMEL_STREAM_SET) == ss->bound_start + i*sizeof(teststring));
- check(camel_stream_read(CAMEL_STREAM(sp), testbuf, sizeof(teststring)) == sizeof(teststring));
- check(memcmp(testbuf, teststring, sizeof(teststring)) == 0);
- check(camel_seekable_stream_tell(sp) == ss->bound_start + (i+1)*sizeof(teststring));
- }
- len = (ss->bound_end-ss->bound_start) % sizeof(teststring);
- check(camel_stream_read(s, testbuf, len) == len);
- check(memcmp(testbuf, teststring, len) == 0);
-
- check(camel_seekable_stream_seek(sp, ss->bound_end - len, CAMEL_STREAM_SET) == ss->bound_end - len);
- check(camel_stream_read(CAMEL_STREAM(sp), testbuf, len) == len);
- check(memcmp(testbuf, teststring, len) == 0);
-
- check(camel_stream_eos(s));
- check(camel_seekable_stream_tell(ss) == ss->bound_end);
- check(camel_seekable_stream_tell(sp) == ss->bound_end);
- check(camel_stream_read(s, testbuf, 1024) == 0);
- check(camel_seekable_stream_tell(ss) == ss->bound_end);
- check(camel_seekable_stream_tell(sp) == ss->bound_end);
- check(camel_stream_eos(s));
- } else {
- /* just 10K */
- for (i=0;i<10240;i++) {
- check(camel_stream_read(s, testbuf, sizeof(teststring)) == sizeof(teststring));
- check(memcmp(testbuf, teststring, sizeof(teststring)) == 0);
- check(camel_seekable_stream_tell(ss) == ss->bound_start + (i+1)*sizeof(teststring));
-
- check(camel_seekable_stream_seek(sp, ss->bound_start + (i)*sizeof(teststring), CAMEL_STREAM_SET) == ss->bound_start + i*sizeof(teststring));
- check(camel_stream_read(CAMEL_STREAM(sp), testbuf, sizeof(teststring)) == sizeof(teststring));
- check(memcmp(testbuf, teststring, sizeof(teststring)) == 0);
- check(camel_seekable_stream_tell(sp) == ss->bound_start + (i+1)*sizeof(teststring));
- }
-
- /* unbound - we dont know the real length */
-#if 0
- end = 10240*sizeof(teststring)+ss->bound_start;
-
- check(camel_seekable_stream_seek(ss, 0, CAMEL_STREAM_END) == end);
- check(camel_seekable_stream_tell(ss) == end);
- /* need to read 0 first to set eos */
- check(camel_stream_read(s, testbuf, 10240) == 0);
- check(camel_stream_eos(s));
-#endif
- }
-
- pull();
-}
diff --git a/camel/tests/lib/streams.h b/camel/tests/lib/streams.h
deleted file mode 100644
index df52e283d0..0000000000
--- a/camel/tests/lib/streams.h
+++ /dev/null
@@ -1,12 +0,0 @@
-
-#include "camel/camel-seekable-stream.h"
-
-/* call one, then the other on the same stream content */
-void test_stream_seekable_writepart(CamelSeekableStream *s);
-void test_stream_seekable_readpart(CamelSeekableStream *s);
-
-/* same, for substreams, multiple ways of writing */
-#define SEEKABLE_SUBSTREAM_WAYS (2)
-
-void test_seekable_substream_writepart(CamelStream *s, int type);
-void test_seekable_substream_readpart(CamelStream *s);