aboutsummaryrefslogtreecommitdiffstats
path: root/camel/tests
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2003-08-16 04:57:30 +0800
committerMichael Zucci <zucchi@src.gnome.org>2003-08-16 04:57:30 +0800
commit87b5d92a77b11d4441b786763b5f409d903cf9c3 (patch)
tree81ea1325b20fda4a84d2815e86e684b65304053b /camel/tests
parent405b846e5b5ab98ecb0d1a3545df3972df044730 (diff)
downloadgsoc2013-evolution-87b5d92a77b11d4441b786763b5f409d903cf9c3.tar.gz
gsoc2013-evolution-87b5d92a77b11d4441b786763b5f409d903cf9c3.tar.zst
gsoc2013-evolution-87b5d92a77b11d4441b786763b5f409d903cf9c3.zip
** See bug #47634.
2003-08-15 Not Zed <NotZed@Ximian.com> ** See bug #47634. * tests/lib/messages.c (test_message_compare): check write_to_stream returns. (message_dump_rec): helper to dump message structure. * camel-mime-part-utils.c (simple_data_wrapper_construct_from_parser): dont set content encoding here. (camel_mime_part_construct_content_from_parser): set it here instead, on every part. basically same as setting the mime_type_field always. * camel-multipart-signed.c (camel_multipart_signed_class_init): * camel-mime-message.c (camel_mime_message_class_init): * camel-multipart.c (camel_multipart_class_init): override decode_to_stream to always do the same as write_to_stream, since we can never be encoded. svn path=/trunk/; revision=22252
Diffstat (limited to 'camel/tests')
-rw-r--r--camel/tests/lib/messages.c66
-rw-r--r--camel/tests/lib/messages.h2
2 files changed, 62 insertions, 6 deletions
diff --git a/camel/tests/lib/messages.c b/camel/tests/lib/messages.c
index 3cf1b5fd51..5a687e8df3 100644
--- a/camel/tests/lib/messages.c
+++ b/camel/tests/lib/messages.c
@@ -189,27 +189,32 @@ test_message_compare (CamelMimeMessage *msg)
CamelStreamMem *mem1, *mem2;
mem1 = (CamelStreamMem *) camel_stream_mem_new ();
- camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, (CamelStream *) mem1);
+ check_msg(camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, (CamelStream *) mem1) != -1, "write_to_stream 1 failed");
camel_stream_reset ((CamelStream *) mem1);
msg2 = camel_mime_message_new ();
- camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg2, (CamelStream *) mem1);
+ check_msg(camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg2, (CamelStream *) mem1) != -1, "construct_from_stream 1 failed");
camel_stream_reset ((CamelStream *) mem1);
mem2 = (CamelStreamMem *) camel_stream_mem_new ();
- camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg2, (CamelStream *) mem2);
+ check_msg(camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg2, (CamelStream *) mem2) != -1, "write_to_stream 2 failed");
camel_stream_reset ((CamelStream *) mem2);
- camel_object_unref (msg2);
-
if (mem1->buffer->len != mem2->buffer->len) {
CamelDataWrapper *content;
printf ("mem1 stream:\n%.*s\n", mem1->buffer->len, mem1->buffer->data);
printf ("mem2 stream:\n%.*s\n\n", mem2->buffer->len, mem2->buffer->data);
-
+
+ printf("msg1:\n");
+ test_message_dump_structure(msg);
+ printf("msg2:\n");
+ test_message_dump_structure(msg2);
+
content = camel_medium_get_content_object ((CamelMedium *) msg);
}
+
+ check_unref(msg2, 1);
check_msg (mem1->buffer->len == mem2->buffer->len,
"mem1->buffer->len = %d, mem2->buffer->len = %d",
@@ -234,3 +239,52 @@ test_message_compare_messages(CamelMimeMessage *m1, CamelMimeMessage *m2)
{
return 0;
}
+
+static void
+message_dump_rec(CamelMimeMessage *msg, CamelMimePart *part, int depth)
+{
+ CamelDataWrapper *containee;
+ int parts, i;
+ char *s;
+ char *mime_type;
+
+ s = alloca(depth+1);
+ memset(s, ' ', depth);
+ s[depth] = 0;
+
+ mime_type = camel_data_wrapper_get_mime_type((CamelDataWrapper *)part);
+ printf("%sPart <%s>\n", s, ((CamelObject *)part)->klass->name);
+ printf("%sContent-Type: %s\n", s, mime_type);
+ g_free(mime_type);
+ printf("%s encoding: %s\n", s, camel_mime_part_encoding_to_string(((CamelDataWrapper *)part)->encoding));
+ printf("%s part encoding: %s\n", s, camel_mime_part_encoding_to_string(part->encoding));
+
+ containee = camel_medium_get_content_object (CAMEL_MEDIUM (part));
+
+ if (containee == NULL)
+ return;
+
+ mime_type = camel_data_wrapper_get_mime_type(containee);
+ printf("%sContent <%s>\n", s, ((CamelObject *)containee)->klass->name);
+ printf ("%sContent-Type: %s\n", s, mime_type);
+ g_free (mime_type);
+ printf("%s encoding: %s\n", s, camel_mime_part_encoding_to_string(((CamelDataWrapper *)containee)->encoding));
+
+ /* using the object types is more accurate than using the mime/types */
+ if (CAMEL_IS_MULTIPART (containee)) {
+ parts = camel_multipart_get_number (CAMEL_MULTIPART (containee));
+ for (i = 0; i < parts; i++) {
+ CamelMimePart *part = camel_multipart_get_part (CAMEL_MULTIPART (containee), i);
+
+ message_dump_rec(msg, part, depth+1);
+ }
+ } else if (CAMEL_IS_MIME_MESSAGE (containee)) {
+ message_dump_rec(msg, (CamelMimePart *)containee, depth+1);
+ }
+}
+
+void
+test_message_dump_structure(CamelMimeMessage *m)
+{
+ message_dump_rec(m, (CamelMimePart *)m, 0);
+}
diff --git a/camel/tests/lib/messages.h b/camel/tests/lib/messages.h
index cdac98f30a..1f892c3cc8 100644
--- a/camel/tests/lib/messages.h
+++ b/camel/tests/lib/messages.h
@@ -11,3 +11,5 @@ 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);
int test_message_compare (CamelMimeMessage *msg);
+
+void test_message_dump_structure(CamelMimeMessage *m);