rfc822: new module.
[ccan] / ccan / rfc822 / test / run-check-check.c
1 #include <ccan/tap/tap.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 #include <signal.h>
6 #include <errno.h>
7
8 #define CCAN_RFC822_DEBUG
9
10 #include <ccan/rfc822/rfc822.h>
11
12 #include <ccan/rfc822/rfc822.c>
13
14 #include "testdata.h"
15
16 static void mangle_list(struct rfc822_msg *msg)
17 {
18         msg->headers.n.prev = NULL;
19 }
20
21 int main(int argc, char *argv[])
22 {
23         void (*mangler)(struct rfc822_msg *msg);
24
25         plan_tests(3 * 1);
26
27         foreach_ptr(mangler, mangle_list) {
28                 const char *buf;
29                 size_t len;
30                 struct rfc822_msg *msg, *check;
31
32                 buf = assemble_msg(&test_msg_1, &len, 0);
33
34                 msg = rfc822_start(NULL, buf, len);
35                 fprintf(stderr, "msg = %p\n", msg);
36
37                 ok1(msg != NULL);
38
39                 (void) rfc822_next_header(msg, NULL);
40
41                 check = rfc822_check(msg, NULL);
42                 fprintf(stderr, "check = %p (1)\n", check);
43                 ok1(check == msg);
44
45                 mangler(msg);
46
47                 check = rfc822_check(msg, NULL);
48                 fprintf(stderr, "check = %p (2)\n", check);
49                 ok1(check == NULL);
50         }
51
52         exit(exit_status());
53 }