]> git.ozlabs.org Git - ccan/blob - ccan/rfc822/test/run-testdata.c
base64: fix for unsigned chars (e.g. ARM).
[ccan] / ccan / rfc822 / test / run-testdata.c
1 #include <config.h>
2
3 #include <stdlib.h>
4 #include <string.h>
5
6 #include <ccan/tap/tap.h>
7 #include <ccan/array_size/array_size.h>
8
9 #define CCAN_RFC822_DEBUG
10
11 #include <ccan/rfc822/rfc822.h>
12 #include <ccan/rfc822/rfc822.c>
13
14 #include "testdata.h"
15
16 /* Test some of the test infrastructure */
17
18 static const char test_msg_1_cmp[] = 
19         "Date:Tue, 22 Feb 2011 00:15:59 +1100\n"
20         "From:Mister From <from@example.com>\n"
21         "To:Mizz To <to@example.org>\n"
22         "Subject:Some subject\n"
23         "Message-ID:<20110221131559.GA28327@example>\n"
24         "MIME-Version:1.0\n"
25         "Content-Type:text/plain; charset=us-ascii\n"
26         "Content-Disposition:inline\n"
27         "\n"
28         "Test message\n";
29
30 static void test_assemble(const struct aexample *e, int crlf,
31                           const char *cmp, size_t cmplen)
32 {
33         const char *msg;
34         size_t len;
35
36         msg = assemble_msg(e, &len, crlf);
37         ok1(msg != NULL);
38         fprintf(stderr, "Assembled message %zd bytes (versus %zd bytes)\n",
39                 len, cmplen);
40         ok1(len == cmplen);
41         ok1(memcmp(msg, cmp, cmplen) == 0);
42         tal_free(msg);
43 }
44
45 int main(int argc, char *argv[])
46 {
47         plan_tests(3);
48
49         test_assemble(&test_msg_1, 0, test_msg_1_cmp, sizeof(test_msg_1_cmp) - 1);
50         exit(exit_status());
51 }