-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathimparse.testc
64 lines (50 loc) · 1.7 KB
/
imparse.testc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <config.h>
#include "cunit/cyrunit.h"
#include "lib/imparse.h"
/* XXX test imparse_word() */
/* XXX test imparse_astring() */
/* tests for imparse_isatom() and imparse_isnatom()
* XXX test strings not just single chars */
static void test_isatom(void)
{
const char contains_null[] = "he\0llo";
const char hello[] = "hello";
/* not an atom if there's a NULL byte in the mapped space */
CU_ASSERT_EQUAL_FATAL(sizeof(contains_null), 7);
CU_ASSERT_EQUAL(imparse_isnatom(contains_null, sizeof(contains_null)), 0);
/*
* https://tools.ietf.org/html/rfc3501#page-81
*
* atom = 1*ATOM-CHAR
*
* ATOM-CHAR = <any CHAR except atom-specials>
*
* atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards /
* quoted-specials / resp-specials
*
* list-wildcards = "%" / "*"
*
* quoted-specials = DQUOTE / "\"
*
* resp-specials = "]"
*/
/* atom-specials */
CU_ASSERT_EQUAL(imparse_isatom("("), 0);
CU_ASSERT_EQUAL(imparse_isatom(")"), 0);
CU_ASSERT_EQUAL(imparse_isatom("{"), 0);
CU_ASSERT_EQUAL(imparse_isatom(" "), 0);
/* XXX CTL */
/* list-wildcards */
CU_ASSERT_EQUAL(imparse_isatom("%"), 0);
CU_ASSERT_EQUAL(imparse_isatom("*"), 0);
/* quoted-specials */
CU_ASSERT_EQUAL(imparse_isatom("\""), 0);
CU_ASSERT_EQUAL(imparse_isatom("\\"), 0);
/* resp-specials */
// XXX - revert this when we block ] in atoms again
CU_ASSERT_NOT_EQUAL(imparse_isatom("]"), 0);
/* make sure it doesn't just always return zero... */
CU_ASSERT_NOT_EQUAL(imparse_isatom(hello), 0);
}
/* XXX test imparse_issequence() */
/* XXX test imparse_isnumber() */