4 #include <asn_internal.h>
5 #include <xer_decoder.h>
8 check(char *tag, char *name, xer_check_tag_e value) {
11 xct = xer_check_tag(tag, strlen(tag), name);
12 printf("[%s] vs [%s]: %d == %d\n",
13 tag, name, xct, value);
18 check_next(char *xerbuf, int expected_chunk_size, pxer_chunk_type_e expected_chunk_type) {
19 int xerbuf_len = strlen(xerbuf);
20 pxer_chunk_type_e ch_type;
24 if(expected_chunk_size == -1)
25 expected_chunk_size = xerbuf_len;
26 ch_size = xer_next_token(&state, xerbuf, xerbuf_len, &ch_type);
28 printf("[%s]:%d\n", xerbuf, xerbuf_len);
29 printf("chunk sizes: %ld vs %ld, chunk types: %d vs %ld\n",
30 (long)ch_size, (long)expected_chunk_size,
31 ch_type, (long)expected_chunk_type
34 if(expected_chunk_type == PXER_WMORE) {
37 assert(ch_size == expected_chunk_size);
38 assert(ch_type == expected_chunk_type);
45 check("", "", XCT_BROKEN);
46 check("<", "", XCT_BROKEN);
47 check(">", "", XCT_BROKEN);
48 check("</", "", XCT_BROKEN);
49 check("/>", "", XCT_BROKEN);
51 check("<>", "", XCT_UNKNOWN_OP);
52 check("</>", "", XCT_UNKNOWN_CL);
54 check("", "a", XCT_BROKEN);
55 check("<>", "a", XCT_UNKNOWN_OP);
56 check("</>", "a", XCT_UNKNOWN_CL);
58 check("a", "a", XCT_BROKEN);
59 check("<a>", "a", XCT_OPENING);
60 check("</a>", "a", XCT_CLOSING);
61 check("</a/>", "a", XCT_BROKEN);
62 check("<a/>", "a", XCT_BOTH);
64 check("<a>", "a", XCT_OPENING);
65 check("</a>", "a", XCT_CLOSING);
66 check("</a/>", "a", XCT_BROKEN);
67 check("<a/>", "a", XCT_BOTH);
69 check("<tag>", "a", XCT_UNKNOWN_OP);
70 check("<tag>", "tag", XCT_OPENING);
71 check("</tag>", "tag", XCT_CLOSING);
72 check("</tag/>", "tag", XCT_BROKEN);
73 check("<tag/>", "tag", XCT_BOTH);
76 check("<tag>", "ta", XCT_UNKNOWN_OP);
77 check("</tag>", "ta", XCT_UNKNOWN_CL);
78 check("</tag/>", "ta", XCT_BROKEN);
79 check("<tag/>", "ta", XCT_UNKNOWN_BO);
81 check("<tag attribute=\"value\"/>", "tag", XCT_BOTH);
83 check_next("<tag/>", -1, PXER_TAG);
84 check_next("<tag", -1, PXER_WMORE);
85 check_next("tag", -1, PXER_TEXT);
86 check_next("tag<s", 3, PXER_TEXT);
87 check_next("</a/>la", 5, PXER_TAG);
88 check_next("<!--blah", -1, PXER_COMMENT);
89 check_next("<!--blah-", -1, PXER_WMORE);
90 check_next("<!--blah--", -1, PXER_WMORE);
91 check_next("<!--blah-->", -1, PXER_COMMENT);