This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include "unistr.h"
22
23 #include <stdlib.h>
24 #include <string.h>
25
26 #include "zerosize-ptr.h"
27 #include "macros.h"
28
29 #define UNIT uint8_t
30 #define U_UCTOMB u8_uctomb
31 #define U32_TO_U u32_to_u8
32 #define U_STRCHR u8_strchr
33 #define U_SET u8_set
34 #include "test-strchr.h"
35
36 int
37 main (void)
38 {
39 test_strchr ();
40
41
42 {
43 char *page_boundary = (char *) zerosize_ptr ();
44
45 if (page_boundary != NULL)
46 {
47 UNIT *mem;
48
49 mem = (UNIT *) (page_boundary - 1 * sizeof (UNIT));
50 mem[0] = 0;
51 ASSERT (u8_strchr (mem, 0x55) == NULL);
52 ASSERT (u8_strchr (mem, 0x123) == NULL);
53 ASSERT (u8_strchr (mem, 0x3456) == NULL);
54 ASSERT (u8_strchr (mem, 0x23456) == NULL);
55
56 mem = (UNIT *) (page_boundary - 2 * sizeof (UNIT));
57 mem[0] = 0x50;
58 mem[1] = 0;
59 ASSERT (u8_strchr (mem, 0x55) == NULL);
60 ASSERT (u8_strchr (mem, 0x123) == NULL);
61 ASSERT (u8_strchr (mem, 0x3456) == NULL);
62 ASSERT (u8_strchr (mem, 0x23456) == NULL);
63
64 mem = (UNIT *) (page_boundary - 3 * sizeof (UNIT));
65 mem[0] = 0x50;
66 mem[1] = 0x50;
67 mem[2] = 0;
68 ASSERT (u8_strchr (mem, 0x55) == NULL);
69 ASSERT (u8_strchr (mem, 0x123) == NULL);
70 ASSERT (u8_strchr (mem, 0x3456) == NULL);
71 ASSERT (u8_strchr (mem, 0x23456) == NULL);
72
73 mem = (UNIT *) (page_boundary - 3 * sizeof (UNIT));
74 mem[0] = 0xC4; mem[1] = 0xA0;
75 mem[2] = 0;
76 ASSERT (u8_strchr (mem, 0x55) == NULL);
77 ASSERT (u8_strchr (mem, 0x123) == NULL);
78 ASSERT (u8_strchr (mem, 0x3456) == NULL);
79 ASSERT (u8_strchr (mem, 0x23456) == NULL);
80
81 mem = (UNIT *) (page_boundary - 3 * sizeof (UNIT));
82 mem[0] = 0xC5; mem[1] = 0xA3;
83 mem[2] = 0;
84 ASSERT (u8_strchr (mem, 0x55) == NULL);
85 ASSERT (u8_strchr (mem, 0x123) == NULL);
86 ASSERT (u8_strchr (mem, 0x3456) == NULL);
87 ASSERT (u8_strchr (mem, 0x23456) == NULL);
88
89 mem = (UNIT *) (page_boundary - 4 * sizeof (UNIT));
90 mem[0] = 0x50;
91 mem[1] = 0x50;
92 mem[2] = 0x50;
93 mem[3] = 0;
94 ASSERT (u8_strchr (mem, 0x55) == NULL);
95 ASSERT (u8_strchr (mem, 0x123) == NULL);
96 ASSERT (u8_strchr (mem, 0x3456) == NULL);
97 ASSERT (u8_strchr (mem, 0x23456) == NULL);
98
99 mem = (UNIT *) (page_boundary - 4 * sizeof (UNIT));
100 mem[0] = 0x50;
101 mem[1] = 0xC5; mem[2] = 0xA3;
102 mem[3] = 0;
103 ASSERT (u8_strchr (mem, 0x55) == NULL);
104 ASSERT (u8_strchr (mem, 0x123) == NULL);
105 ASSERT (u8_strchr (mem, 0x3456) == NULL);
106 ASSERT (u8_strchr (mem, 0x23456) == NULL);
107 ASSERT (u8_strchr (mem, 0x163) == mem + 1);
108
109 mem = (UNIT *) (page_boundary - 4 * sizeof (UNIT));
110 mem[0] = 0xE3; mem[1] = 0x91; mem[2] = 0x00;
111 mem[3] = 0;
112 ASSERT (u8_strchr (mem, 0x55) == NULL);
113 ASSERT (u8_strchr (mem, 0x123) == NULL);
114 ASSERT (u8_strchr (mem, 0x3456) == NULL);
115 ASSERT (u8_strchr (mem, 0x23456) == NULL);
116
117 mem = (UNIT *) (page_boundary - 4 * sizeof (UNIT));
118 mem[0] = 0xE3; mem[1] = 0x92; mem[2] = 0x96;
119 mem[3] = 0;
120 ASSERT (u8_strchr (mem, 0x55) == NULL);
121 ASSERT (u8_strchr (mem, 0x123) == NULL);
122 ASSERT (u8_strchr (mem, 0x3456) == NULL);
123 ASSERT (u8_strchr (mem, 0x23456) == NULL);
124
125 mem = (UNIT *) (page_boundary - 5 * sizeof (UNIT));
126 mem[0] = 0x50;
127 mem[1] = 0x50;
128 mem[2] = 0x50;
129 mem[3] = 0x50;
130 mem[4] = 0;
131 ASSERT (u8_strchr (mem, 0x55) == NULL);
132 ASSERT (u8_strchr (mem, 0x123) == NULL);
133 ASSERT (u8_strchr (mem, 0x3456) == NULL);
134 ASSERT (u8_strchr (mem, 0x23456) == NULL);
135
136 mem = (UNIT *) (page_boundary - 5 * sizeof (UNIT));
137 mem[0] = 0x50;
138 mem[1] = 0xE3; mem[2] = 0x92; mem[3] = 0x96;
139 mem[4] = 0;
140 ASSERT (u8_strchr (mem, 0x55) == NULL);
141 ASSERT (u8_strchr (mem, 0x123) == NULL);
142 ASSERT (u8_strchr (mem, 0x3456) == NULL);
143 ASSERT (u8_strchr (mem, 0x23456) == NULL);
144 ASSERT (u8_strchr (mem, 0x3496) == mem + 1);
145 }
146 }
147
148 return 0;
149 }