diff options
author | Not Zed <NotZed@Ximian.com> | 2003-04-10 19:35:00 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2003-04-10 19:35:00 +0800 |
commit | 2e7d1434aedfbb634ede57faf6741dae5419d520 (patch) | |
tree | c899efdc2fdbce344fbced33e345868d4259a37c /camel/tests | |
parent | 0933b12476c210975487cd29c3e05a0f248eac04 (diff) | |
download | gsoc2013-evolution-2e7d1434aedfbb634ede57faf6741dae5419d520.tar gsoc2013-evolution-2e7d1434aedfbb634ede57faf6741dae5419d520.tar.gz gsoc2013-evolution-2e7d1434aedfbb634ede57faf6741dae5419d520.tar.bz2 gsoc2013-evolution-2e7d1434aedfbb634ede57faf6741dae5419d520.tar.lz gsoc2013-evolution-2e7d1434aedfbb634ede57faf6741dae5419d520.tar.xz gsoc2013-evolution-2e7d1434aedfbb634ede57faf6741dae5419d520.tar.zst gsoc2013-evolution-2e7d1434aedfbb634ede57faf6741dae5419d520.zip |
filter data test cases.
2003-04-10 Not Zed <NotZed@Ximian.com>
* tests/mime-filter/data: filter data test cases.
* tests/mime-filter/test-tohtml.c: New test for html filter.
** See bug #40969
* camel-mime-filter-tohtml.c (html_convert): Change the logic
slightly, scan a whole line within the main loop.
svn path=/trunk/; revision=20799
Diffstat (limited to 'camel/tests')
-rw-r--r-- | camel/tests/mime-filter/Makefile.am | 5 | ||||
-rw-r--r-- | camel/tests/mime-filter/data/html.0.in | 10 | ||||
-rw-r--r-- | camel/tests/mime-filter/data/html.0.out | 10 | ||||
-rw-r--r-- | camel/tests/mime-filter/data/html.1.in | 10 | ||||
-rw-r--r-- | camel/tests/mime-filter/data/html.1.out | 10 | ||||
-rw-r--r-- | camel/tests/mime-filter/test-tohtml.c | 132 |
6 files changed, 175 insertions, 2 deletions
diff --git a/camel/tests/mime-filter/Makefile.am b/camel/tests/mime-filter/Makefile.am index 2c83f1202f..21635f839f 100644 --- a/camel/tests/mime-filter/Makefile.am +++ b/camel/tests/mime-filter/Makefile.am @@ -27,9 +27,10 @@ EXTRA_DIST = \ check_PROGRAMS = \ test-crlf \ - test-charset + test-charset \ + test-tohtml -TESTS = test-crlf test-charset +TESTS = test-crlf test-charset test-tohtml diff --git a/camel/tests/mime-filter/data/html.0.in b/camel/tests/mime-filter/data/html.0.in new file mode 100644 index 0000000000..217f85b4ff --- /dev/null +++ b/camel/tests/mime-filter/data/html.0.in @@ -0,0 +1,10 @@ + +College of Engineering Students, + +We are contacting you to request that you consider nominating a College +of Engineering faculty member for the College's 2003 Excellence in +Teaching Award. The award criteria and nomination form are attached. +They can also be found on the web at: + + <http://www.ce.udel.edu/teaching_award.html> + <http://www.ce.udel.edu/nomination_form.html> diff --git a/camel/tests/mime-filter/data/html.0.out b/camel/tests/mime-filter/data/html.0.out new file mode 100644 index 0000000000..3f19310dd4 --- /dev/null +++ b/camel/tests/mime-filter/data/html.0.out @@ -0,0 +1,10 @@ + +College of Engineering Students, + +We are contacting you to request that you consider nominating a College +of Engineering faculty member for the College's 2003 Excellence in +Teaching Award. The award criteria and nomination form are attached. +They can also be found on the web at: + +	<<a href="http://www.ce.udel.edu/teaching_award.html">http://www.ce.udel.edu/teaching_award.html</a>> +	<<a href="http://www.ce.udel.edu/nomination_form.html">http://www.ce.udel.edu/nomination_form.html</a>> diff --git a/camel/tests/mime-filter/data/html.1.in b/camel/tests/mime-filter/data/html.1.in new file mode 100644 index 0000000000..8dece6113d --- /dev/null +++ b/camel/tests/mime-filter/data/html.1.in @@ -0,0 +1,10 @@ + +College of Engineering Students, + +We are contacting you to request that you consider nominating a College +of Engineering faculty member for the College's 2003 Excellence in +Teaching Award. The award criteria and nomination form are attached. +They can also be found on the web at: + + <http://www.ce.udel.edu/teaching_award.html> + <http://www.ce.udel.edu/nomination_form.html>
\ No newline at end of file diff --git a/camel/tests/mime-filter/data/html.1.out b/camel/tests/mime-filter/data/html.1.out new file mode 100644 index 0000000000..3f19310dd4 --- /dev/null +++ b/camel/tests/mime-filter/data/html.1.out @@ -0,0 +1,10 @@ + +College of Engineering Students, + +We are contacting you to request that you consider nominating a College +of Engineering faculty member for the College's 2003 Excellence in +Teaching Award. The award criteria and nomination form are attached. +They can also be found on the web at: + +	<<a href="http://www.ce.udel.edu/teaching_award.html">http://www.ce.udel.edu/teaching_award.html</a>> +	<<a href="http://www.ce.udel.edu/nomination_form.html">http://www.ce.udel.edu/nomination_form.html</a>> diff --git a/camel/tests/mime-filter/test-tohtml.c b/camel/tests/mime-filter/test-tohtml.c new file mode 100644 index 0000000000..5b7842fefe --- /dev/null +++ b/camel/tests/mime-filter/test-tohtml.c @@ -0,0 +1,132 @@ +/* + test-html.c + + Test the CamelMimeFilterToHTML class +*/ + +#include <sys/stat.h> +#include <unistd.h> + +#include <stdio.h> +#include <string.h> +#include <sys/types.h> +#include <dirent.h> + +#include "camel-test.h" + +#include <camel/camel-stream-fs.h> +#include <camel/camel-stream-mem.h> +#include <camel/camel-stream-filter.h> +#include <camel/camel-mime-filter-tohtml.h> + +#define d(x) x + +#define CHUNK_SIZE 4096 + +static void +test_filter(CamelMimeFilter *f, const char *inname, const char *outname) +{ + CamelStreamMem *in, *out; + CamelStream *indisk, *outdisk, *filter; + int id; + + camel_test_push("Data file `%s'", inname); + + camel_test_push("setup"); + + indisk = camel_stream_fs_new_with_name(inname, O_RDONLY, 0); + check(indisk); + outdisk = camel_stream_fs_new_with_name(outname, O_RDONLY, 0); + check(outdisk); + + out = (CamelStreamMem *)camel_stream_mem_new(); + check(camel_stream_write_to_stream(outdisk, (CamelStream *)out) > 0); + + camel_test_pull(); + + camel_test_push("reading through filter stream"); + + in = (CamelStreamMem *)camel_stream_mem_new(); + + filter = (CamelStream *)camel_stream_filter_new_with_stream(indisk); + check_count(indisk, 2); + id = camel_stream_filter_add((CamelStreamFilter *)filter, f); + check_count(f, 2); + + check(camel_stream_write_to_stream(filter, (CamelStream *)in) > 0); + check_msg(in->buffer->len == out->buffer->len + && memcmp(in->buffer->data, out->buffer->data, in->buffer->len) == 0, + "Buffer content mismatch, %d != %d, in = '%.*s' != out = '%.*s'", in->buffer->len, out->buffer->len, + in->buffer->len, in->buffer->data, out->buffer->len, out->buffer->data); + + camel_test_pull(); + + camel_stream_filter_remove((CamelStreamFilter *)filter, id); + check_count(f, 1); + camel_mime_filter_reset(f); + + check_unref(filter, 1); + check_count(indisk, 1); + check_count(f, 1); + check_unref(in, 1); + + check(camel_stream_reset(indisk) == 0); + + camel_test_push("writing through filter stream"); + + in = (CamelStreamMem *)camel_stream_mem_new(); + filter = (CamelStream *)camel_stream_filter_new_with_stream((CamelStream *)in); + check_count(in, 2); + id = camel_stream_filter_add((CamelStreamFilter *)filter, f); + check_count(f, 2); + + check(camel_stream_write_to_stream(indisk, filter) > 0); + check(camel_stream_flush(filter) == 0); + check_msg(in->buffer->len == out->buffer->len + && memcmp(in->buffer->data, out->buffer->data, in->buffer->len) == 0, + "Buffer content mismatch, %d != %d, in = '%.*s' != out = '%.*s'", in->buffer->len, out->buffer->len, + in->buffer->len, in->buffer->data, out->buffer->len, out->buffer->data); + + camel_stream_filter_remove((CamelStreamFilter *)filter, id); + check_unref(filter, 1); + check_unref(in, 1); + check_unref(indisk, 1); + check_unref(outdisk, 1); + check_unref(out, 1); + + camel_test_pull(); + + camel_test_pull(); +} + +int +main (int argc, char **argv) +{ + int i; + + camel_test_init(argc, argv); + + camel_test_start("HTML Stream filtering"); + + for (i=0;i<100;i++) { + char inname[32], outname[32]; + CamelMimeFilter *f; + struct stat st; + + sprintf(inname, "data/html.%d.in", i); + sprintf(outname, "data/html.%d.out", i); + + if (stat(inname, &st) == -1) + break; + + f = camel_mime_filter_tohtml_new(CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); + + test_filter(f, inname, outname); + + check_unref(f, 1); + } + + camel_test_end(); + + return 0; +} |