blob: e12037ca04fcf43d197863fef9da2d44ee277f0f [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
3 *
4 * FILE: dat_strcoll.c
5 *
6 * STRCOLL: int strcoll (const char *s1, const char *s2);
7 */
8
9/*
10 NOTE:
11
12 If a return value is expected to be 0, set ret_flg=1 and the
13 expected value = 0. If a return value is expected to be a
14 positive/negative value, set ret_flg=0, and set the expected value
15 = +1/-1.
16 There is inconsistensy between tst_strcoll() and tst_wcscoll()(it
17 has cmp_flg) for input data. I'll fix it.
18
19 Assuming en_US to be en_US.ascii. (maybe, should be iso8859-1).
20
21
22
23 ASCII CODE : A,B,C, ... , a, b, c, ... B,a:-1 a,B:+1
24 DICTIONARY : A,a,B,b,C,c,.... a,B:-1 B,a:+1 */
25
26TST_STRCOLL tst_strcoll_loc [] = {
27 {
28 { Tstrcoll, TST_LOC_de },
29 {
30 { /*input.*/ { "ÄBCDEFG", "ÄBCDEFG" }, /* #1 */
31 /*expect*/ { 0,1,0, },
32 },
33 { /*input.*/ { "XX Ä XX", "XX B XX" }, /* #2 */
34 /*expect*/ { 0,0,-1, },
35 },
36 { /*input.*/ { "XX B XX", "XX Ä XX" }, /* #3 */
37 /*expect*/ { 0,0,+1, },
38 },
39 { /*input.*/ { "B", "a" }, /* #4 */
40 /*expect*/ { 0,0,+1, },
41 },
42 { /*input.*/ { "a", "B" }, /* #5 */
43 /*expect*/ { 0,0,-1, },
44 },
45 { /*input.*/ { "b", "A" }, /* #6 */
46 /*expect*/ { 0,0,+1, },
47 },
48 { /*input.*/ { "A", "b" }, /* #7 */
49 /*expect*/ { 0,0,-1, },
50 },
51 { /*input.*/ { "ä", "B" }, /* #8 */
52 /*expect*/ { 0,0,-1, },
53 },
54 { /*input.*/ { "B", "ä" }, /* #9 */
55 /*expect*/ { 0,0,+1, },
56 },
57 { .is_last = 1 } /* Last element. */
58 }
59 },
60 {
61 { Tstrcoll, TST_LOC_en },
62 {
63 { /*input.*/ { "ABCDEFG", "ABCDEFG" }, /* #1 */
64 /*expect*/ { 0,1,0, },
65 },
66 { /*input.*/ { "XX a XX", "XX B XX" }, /* #2 */
67 /*expect*/ { 0,0,-1, },
68 },
69 { /*input.*/ { "XX B XX", "XX a XX" }, /* #3 */
70 /*expect*/ { 0,0,+1, },
71 },
72 {
73 /* <WAIVER> */
74 /*input.*/ { "B", "a" }, /* #4 */
75#ifdef SHOJI_IS_RIGHT
76 /*expect*/ { 0,0,-1, },
77#else
78 /* XXX We are not testing the C locale. */
79 /*expect*/ { 0,0,+1, },
80#endif
81 },
82 {
83 /* <WAIVER> */
84 /*input.*/ { "a", "B" }, /* #5 */
85#ifdef SHOJI_IS_RIGHT
86 /*expect*/ { 0,0,+1, },
87#else
88 /* XXX We are not testing the C locale. */
89 /*expect*/ { 0,0,-1, },
90#endif
91 },
92 { /*input.*/ { "b", "A" }, /* #6 */
93 /*expect*/ { 0,0,+1, },
94 },
95 { /*input.*/ { "A", "b" }, /* #7 */
96 /*expect*/ { 0,0,-1, },
97 },
98#ifdef NO_WAIVER
99 /* XXX I do not yet know whether strcoll really should reject
100 characters outside the multibyte character range. */
101 {
102 /* #8 */ /* <WAIVER> */
103 /*input.*/ { "\244\242\244\244\244\246\244\250\244\252", "ABCDEFG" },
104 /*expect*/ { EINVAL,0,0, },
105 },
106 {
107 /* #9 */ /* <WAIVER> */
108 /*input.*/ { "ABCZEFG", "\244\242\244\244\244\246\244\250\244\252" },
109 /*expect*/ { EINVAL,0,0, },
110 },
111#endif
112 { .is_last = 1 } /* Last element. */
113 }
114 },
115#if 0
116 {
117 { Tstrcoll, TST_LOC_eucJP },
118 {
119 { /*input.*/ { "\244\242\244\244\244\246\244\250\244\252",
120 "\244\242\244\244\244\246\244\250\244\252" }, /* #1 */
121 /*expect*/ { 0,1,0, },
122 },
123 { /*input.*/ { "\244\242\244\244\244\246\244\250\244\252",
124 "\244\242\244\244\244\363\244\250\244\252" }, /* #2 */
125 /*expect*/ { 0,0,-1, },
126 },
127 { /*input.*/ { "\244\242\244\244\244\363\244\250\244\252",
128 "\244\242\244\244\244\246\244\250\244\252" }, /* #3 */
129 /*expect*/ { 0,0,+1, },
130 },
131 { /*input.*/ { "B", "a" }, /* #4 */
132 /*expect*/ { 0,0,-1, },
133 },
134 { /*input.*/ { "a", "B" }, /* #5 */
135 /*expect*/ { 0,0,+1, },
136 },
137 { /*input.*/ { "b", "A" }, /* #6 */
138 /*expect*/ { 0,0,+1, },
139 },
140 { /*input.*/ { "A", "b" }, /* #7 */
141 /*expect*/ { 0,0,-1, },
142 },
143#ifdef NO_WAIVER
144 /* XXX I do not yet know whether strcoll really should reject
145 characters outside the multibyte character range. */
146 {
147 /* <WAIVER> */
148 /*input.*/ { "\200\216\217", "ABCDEFG" }, /* #8 */
149 /*expect*/ { EINVAL,0,0, },
150 },
151 {
152 /* <WAIVER> */
153 /*input.*/ { "ABCZEFG", "\200\216\217" }, /* #9 */
154 /*expect*/ { EINVAL,0,0, },
155 },
156#endif
157 { .is_last = 1 } /* Last element. */
158 }
159 },
160#else
161 {
162 { Tstrcoll, TST_LOC_ja_UTF8 },
163 {
164 { /*input.*/ { "\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212",
165 "\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212" }, /* #1 */
166 /*expect*/ { 0,1,0, },
167 },
168 { /*input.*/ { "\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212",
169 "\343\201\202\343\201\204\343\202\223\343\201\210\343\201\212" }, /* #2 */
170 /*expect*/ { 0,0,-1, },
171 },
172 { /*input.*/ { "\343\201\202\343\201\204\343\202\223\343\201\210\343\201\212",
173 "\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212" }, /* #3 */
174 /*expect*/ { 0,0,+1, },
175 },
176 { /*input.*/ { "B", "a" }, /* #4 */
177 /*expect*/ { 0,0,-1, },
178 },
179 { /*input.*/ { "a", "B" }, /* #5 */
180 /*expect*/ { 0,0,+1, },
181 },
182 { /*input.*/ { "b", "A" }, /* #6 */
183 /*expect*/ { 0,0,+1, },
184 },
185 { /*input.*/ { "A", "b" }, /* #7 */
186 /*expect*/ { 0,0,-1, },
187 },
188#ifdef NO_WAIVER
189 /* XXX I do not yet know whether strcoll really should reject
190 characters outside the multibyte character range. */
191 {
192 /* <WAIVER> */
193 /*input.*/ { "\200\216\217", "ABCDEFG" }, /* #8 */
194 /*expect*/ { EINVAL,0,0, },
195 },
196 {
197 /* <WAIVER> */
198 /*input.*/ { "ABCZEFG", "\200\216\217" }, /* #9 */
199 /*expect*/ { EINVAL,0,0, },
200 },
201#endif
202 { .is_last = 1 } /* Last element. */
203 }
204 },
205#endif
206 {
207 { Tstrcoll, TST_LOC_end }
208 }
209};