This source file includes following definitions.
- test_cmp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 static void
20 test_cmp (void)
21 {
22
23 void *page_boundary1 = zerosize_ptr ();
24 void *page_boundary2 = zerosize_ptr ();
25 if (page_boundary1 && page_boundary2)
26 ASSERT (U_CMP (page_boundary1, page_boundary2, 0) == 0);
27 {
28 static const UNIT input1[] = { 'f', 'o', 'o', 0 };
29 static const UNIT input2[] = { 'f', 'o', 'o', 'b', 'a', 'r', 0 };
30 ASSERT (U_CMP (input1, input2, 2) == 0);
31 ASSERT (U_CMP (input1, input2, 3) == 0);
32 ASSERT (U_CMP (input1, input2, 4) != 0);
33 }
34 {
35 static const UNIT input1[] = { 'f', 'o', 'o', 0 };
36 static const UNIT input2[] = { 'b', 'a', 'r', 0 };
37 ASSERT (U_CMP (input1, input2, 1) != 0);
38 ASSERT (U_CMP (input1, input2, 3) != 0);
39 }
40
41
42 {
43 static const UNIT input1[] = { 'f', 'o', 'o', 0 };
44 static const UNIT input2[] = { 'm', 'o', 'o', 0 };
45 ASSERT (U_CMP (input1, input2, 4) < 0);
46 ASSERT (U_CMP (input2, input1, 4) > 0);
47 }
48 {
49 static const UNIT input1[] = { 'o', 'o', 'm', 'p', 'h', 0 };
50 static const UNIT input2[] = { 'o', 'o', 'p', 's', 0 };
51 ASSERT (U_CMP (input1, input2, 3) < 0);
52 ASSERT (U_CMP (input2, input1, 3) > 0);
53 }
54 {
55 static const UNIT input1[] = { 'f', 'o', 'o', 0 };
56 static const UNIT input2[] = { 'f', 'o', 'o', 'b', 'a', 'r', 0 };
57 ASSERT (U_CMP (input1, input2, 4) < 0);
58 ASSERT (U_CMP (input2, input1, 4) > 0);
59 }
60
61
62 {
63 static const UNIT input1[] = { 0x40 };
64 static const UNIT input2[] = { 0xC2 };
65 ASSERT (U_CMP (input1, input2, 1) < 0);
66 ASSERT (U_CMP (input2, input1, 1) > 0);
67 }
68 {
69 static const UNIT input1[] = { 0xC2 };
70 static const UNIT input2[] = { 0xC3 };
71 ASSERT (U_CMP (input1, input2, 1) < 0);
72 ASSERT (U_CMP (input2, input1, 1) > 0);
73 }
74
75
76
77
78 {
79 UNIT foo[21];
80 UNIT bar[21];
81 int i;
82 for (i = 0; i < 4; i++)
83 {
84 UNIT *a = foo + i;
85 UNIT *b = bar + i;
86 int j;
87 for (j = 0; j < 8; j++)
88 a[j] = '-';
89 a[8] = '0';
90 for (j = 9; j < 16; j++)
91 a[j] = '1';
92 for (j = 0; j < 8; j++)
93 b[j] = '-';
94 b[8] = '1';
95 for (j = 9; j < 16; j++)
96 b[j] = '0';
97 ASSERT (U_CMP (a, b, 16) < 0);
98 }
99 }
100 }