This source file includes following definitions.
- check_single
- check
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 static void
20 check_single (const UNIT *input, size_t length, size_t n)
21 {
22 static const UNIT base[] = { 'C', 'h', 'a', 'n', 'g', 'i', 'n', 'g', 0 };
23 size_t m;
24
25 for (m = 0; m < SIZEOF (base); m++)
26 {
27 UNIT *dest;
28 UNIT *result;
29 size_t i;
30
31 dest = (UNIT *) malloc ((1 + m + n + 2) * sizeof (UNIT));
32 ASSERT (dest != NULL);
33
34 dest[0] = MAGIC;
35 for (i = 0; i < m; i++)
36 dest[1 + i] = base[i];
37 dest[1 + m] = 0;
38 for (i = 1; i < n + 2; i++)
39 dest[1 + m + i] = MAGIC;
40
41 result = U_STRNCAT (dest + 1, input, n);
42 ASSERT (result == dest + 1);
43
44 ASSERT (dest[0] == MAGIC);
45 for (i = 0; i < m; i++)
46 ASSERT (dest[1 + i] == base[i]);
47 for (i = 0; i < (n <= length ? n : length); i++)
48 ASSERT (dest[1 + m + i] == input[i]);
49 ASSERT (dest[1 + m + i] == 0);
50 ASSERT (dest[1 + m + i + 1] == MAGIC);
51
52 free (dest);
53 }
54 }
55
56 static void
57 check (const UNIT *input, size_t input_length)
58 {
59 size_t length;
60 size_t n;
61
62 ASSERT (input_length > 0);
63 ASSERT (input[input_length - 1] == 0);
64 length = input_length - 1;
65
66 for (n = 0; n <= 2 * length + 2; n++)
67 check_single (input, length, n);
68
69
70
71 {
72 char *page_boundary = (char *) zerosize_ptr ();
73
74 if (page_boundary != NULL)
75 {
76 for (n = 0; n <= 2 * length + 2; n++)
77 {
78 size_t n_to_copy = (n <= length ? n : length + 1);
79 UNIT *copy;
80 size_t i;
81
82 copy = (UNIT *) page_boundary - n_to_copy;
83 for (i = 0; i < n_to_copy; i++)
84 copy[i] = input[i];
85
86 check_single (copy, length, n);
87 }
88 }
89 }
90 }