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 UNIT *dest;
23 UNIT *result;
24 size_t i;
25
26 dest = (UNIT *) malloc ((1 + n + 1) * sizeof (UNIT));
27 ASSERT (dest != NULL);
28
29 for (i = 0; i < 1 + n + 1; i++)
30 dest[i] = MAGIC;
31
32 result = U_STPNCPY (dest + 1, input, n);
33 ASSERT (result == dest + 1 + (n <= length ? n : length));
34
35 ASSERT (dest[0] == MAGIC);
36 for (i = 0; i < (n <= length ? n : length + 1); i++)
37 ASSERT (dest[1 + i] == input[i]);
38 for (; i < n; i++)
39 ASSERT (dest[1 + i] == 0);
40 ASSERT (dest[1 + n] == MAGIC);
41
42 free (dest);
43 }
44
45 static void
46 check (const UNIT *input, size_t input_length)
47 {
48 size_t length;
49 size_t n;
50
51 ASSERT (input_length > 0);
52 ASSERT (input[input_length - 1] == 0);
53 length = input_length - 1;
54
55 for (n = 0; n <= 2 * length + 2; n++)
56 check_single (input, length, n);
57
58
59
60 {
61 char *page_boundary = (char *) zerosize_ptr ();
62
63 if (page_boundary != NULL)
64 {
65 for (n = 0; n <= 2 * length + 2; n++)
66 {
67 size_t n_to_copy = (n <= length ? n : length + 1);
68 UNIT *copy;
69 size_t i;
70
71 copy = (UNIT *) page_boundary - n_to_copy;
72 for (i = 0; i < n_to_copy; i++)
73 copy[i] = input[i];
74
75 check_single (copy, length, n);
76 }
77 }
78 }
79 }