1 /*
2  *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
3  *
4  *	 FILE: dat_wcscoll.c
5  *
6  *	 WCSCOLL:  int	wcscoll (const wchar_t *ws1, const wchar_t *ws2);
7  */
8 
9 /*
10  *  CAUTION:
11  *	     When LC_COLLATE (or LC_ALL) is set for ja_JP.EUC,
12  *	     wcscoll() core-dumps for big values such as 0x3041
13  *	     (0x0041 is okay) in glibc 2.1.2.
14  *
15  *  NOTE:
16  *    a) When 0 is expected as a return value, set ret_flg=1.
17  *	 - the return value is compared with an expected value: ret_val.
18  *    b) When a positive value is expected as a return value,
19  *	 set ret_flg=0 and set cmp_flg=+1.
20  *	 - the return value is not compared with the expected value
21  *	   (can not be compared); instead, the test program checks
22  *	   if the return value is positive when cmp_flg=+1.
23  *    c) When a negative value is expected as a return value,
24  *	 ......
25  *    d) When data contains invalid values, set err_val to the expected errno.
26  *	 Set ret_flg=0 and cmp_flg=0 so that it doesn't compare
27  *	 the return value with an expected value or doesn't check
28  *	 the sign of the return value.
29  *
30  *
31  *	     -------------------------------------------
32  *	     CASE  err_val   ret_flg  ret_val	 cmp_flg
33  *	     -------------------------------------------
34  *	      a)      0	 1	  0	    0
35  *	      b)      0	 0	  0	   +1
36  *	      c)      0	 0	  0	   -1
37  *	      d)    EINVAL	 0	  0	    0
38  *	     -------------------------------------------
39  */
40 
41 
42 TST_WCSCOLL tst_wcscoll_loc [] = {
43 
44     {	{ Twcscoll, TST_LOC_de },
45 	{
46 	  { /*input.*/ { { 0x00E1,0x00E2,0x00E3,0x0000 },
47 			 { 0x00E1,0x00E2,0x00E3,0x0000 }, },  /* #1 */
48 	    /*expect*/ { 0,1,0, 0,			  },
49 	  },
50 	  { /*input.*/ { { 0x0000,0x00E1,0x00E3,0x0000 },
51 			 { 0x0000,0x00E2,0x00E3,0x0000 }, },  /* #2 */
52 	    /*expect*/ { 0,1,0, 0,			  },
53 	  },
54 	  { /*input.*/ { { 0x00E1,0x00E1,0x00E3,0x0000 },
55 			 { 0x0000,0x00E2,0x00E3,0x0000 }, },  /* #3 */
56 	    /*expect*/ { 0,0,0, +1,			  },
57 	  },
58 	  { /*input.*/ { { 0x0000,0x00E2,0x00E3,0x0000 },
59 			 { 0x00E1,0x00E1,0x00E3,0x0000 }, },  /* #4 */
60 	    /*expect*/ { 0,0,0, -1,			  },
61 	  },
62 	  { /*input.*/ { { 0x00E1,0x0042,0x00E3,0x0000 },
63 			 { 0x00E1,0x0061,0x00E3,0x0000 }, },  /* #5 */
64 	    /*expect*/ { 0,0,0, +1,			  },
65 	  },
66 	  { /*input.*/ { { 0x00E1,0x0061,0x00E3,0x0000 },
67 			 { 0x00E1,0x0042,0x00E3,0x0000 }, },  /* #6 */
68 	    /*expect*/ { 0,0,0, -1,			  },
69 	  },
70 	  { /*input.*/ { { 0x00E1,0x00E2,0x0000	       },
71 			 { 0x00E1,0x00E2,0x00E9,0x0000 }, },  /* #7 */
72 	    /*expect*/ { 0,0,0, -1,			  },
73 	  },
74 	  { /*input.*/ { { 0x00E1,0x00E2,0x00E9,0x0000 },
75 			 { 0x00E1,0x00E2,0x0000	       }, },  /* #8 */
76 	    /*expect*/ { 0,0,0, +1,			  },
77 	  },
78 	  { /*input.*/ { { 0x00E1,0x0092,0x00E9,0x0000 },
79 			 { 0x00E1,0x008E,0x00E9,0x0000 }, },  /* #9 */
80 	    /*expect*/ { 0,0,0, +1,		       },
81 	  },
82 	  { /*input.*/ { { 0x00E1,0x008E,0x00E9,0x0000 },
83 			 { 0x00E1,0x0092,0x00E9,0x0000 }, },  /* #10 */
84 	    /*expect*/ { 0,0,0, -1,		       },
85 	  },
86 	  { .is_last = 1 }
87 	}
88     },
89     {	{ Twcscoll, TST_LOC_enUS },
90 	{
91 	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
92 			 { 0x0041,0x0042,0x0043,0x0000 }, },  /* #1 */
93 	    /*expect*/ { 0,1,0, 0,			  },
94 	  },
95 	  { /*input.*/ { { 0x0000,0x0041,0x0043,0x0000 },
96 			 { 0x0000,0x0042,0x0043,0x0000 }, },  /* #2 */
97 	    /*expect*/ { 0,1,0, 0,			  },
98 	  },
99 	  { /*input.*/ { { 0x0041,0x0041,0x0043,0x0000 },
100 			 { 0x0000,0x0042,0x0043,0x0000 }, },  /* #3 */
101 	    /*expect*/ { 0,0,0, +1,			  },
102 	  },
103 	  { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 },
104 			 { 0x0041,0x0041,0x0043,0x0000 }, },  /* #4 */
105 	    /*expect*/ { 0,0,0, -1,			  },
106 	  },
107 	  /* XXX Correct order is lowercase before uppercase.  */
108 	  { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 },
109 			 { 0x0041,0x0061,0x0043,0x0000 }, },  /* #5 */
110 	    /*expect*/ { 0,0,0, +1,			  },
111 	  },
112 	  { /*input.*/ { { 0x0041,0x0061,0x0043,0x0000 },
113 			 { 0x0041,0x0042,0x0043,0x0000 }, },  /* #6 */
114 	    /*expect*/ { 0,0,0, -1,			  },
115 	  },
116 	  { /*input.*/ { { 0x0041,0x0042,0x0000	       },
117 			 { 0x0041,0x0042,0x0049,0x0000 }, },  /* #7 */
118 	    /*expect*/ { 0,0,0, -1,			  },
119 	  },
120 	  { /*input.*/ { { 0x0041,0x0042,0x0049,0x0000 },
121 			 { 0x0041,0x0042,0x0000	       }, },  /* #8 */
122 	    /*expect*/ { 0,0,0, +1,			  },
123 	  },
124 	  /* Do not assume position of character out of range.  */
125 	  { /*input.*/ { { 0x0041,0x0092,0x0049,0x0000 },
126 			 { 0x0041,0x008E,0x0049,0x0000 }, },  /* #9 */
127 	    /*expect*/ { 0,0,0, 0,		       },
128 	  },
129 	  { /*input.*/ { { 0x0041,0x008E,0x0049,0x0000 },
130 			 { 0x0041,0x0092,0x0049,0x0000 }, },  /* #10 */
131 	    /*expect*/ { 0,0,0, 0,		       },
132 	  },
133 	  { .is_last = 1 }
134 	}
135     },
136     {	{ Twcscoll, TST_LOC_eucJP },
137 	{
138 	  { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 },
139 			 { 0x3041,0x3042,0x3043,0x0000 }, },  /* #1 */
140 	    /*expect*/ { 0,1,0, 0,			  },
141 	  },
142 	  { /*input.*/ { { 0x0000,0x3041,0x3043,0x0000 },
143 			 { 0x0000,0x3042,0x3043,0x0000 }, },  /* #2 */
144 	    /*expect*/ { 0,1,0, 0,			  },
145 	  },
146 	  { /*input.*/ { { 0x3041,0x3041,0x3043,0x0000 },
147 			 { 0x0000,0x3042,0x3043,0x0000 }, },  /* #3 */
148 	    /*expect*/ { 0,0,0, +1,			  },
149 	  },
150 	  { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 },
151 			 { 0x3041,0x3041,0x3043,0x0000 }, },  /* #4 */
152 	    /*expect*/ { 0,0,0, -1,			  },
153 	  },
154 	  { /*input.*/ { { 0x3041,0x0042,0x3043,0x0000 },
155 			 { 0x3041,0x0061,0x3043,0x0000 }, },  /* #5 */
156 	    /*expect*/ { 0,0,0, -1,			  },
157 	  },
158 	  { /*input.*/ { { 0x3041,0x0061,0x3043,0x0000 },
159 			 { 0x3041,0x0042,0x3043,0x0000 }, },  /* #6 */
160 	    /*expect*/ { 0,0,0, +1,			  },
161 	  },
162 	  { /*input.*/ { { 0x3041,0x3042,0xFF71,0x0000 },
163 			 { 0x3041,0x3042,0x30A2,0x0000 }, },  /* #7 */
164 	    /*expect*/ { 0,0,0, -1,			  },
165 	  },
166 	  { /*input.*/ { { 0x3041,0x3042,0x30A2,0x0000 },
167 			 { 0x3041,0x3042,0xFF71,0x0000 }, },  /* #8 */
168 	    /*expect*/ { 0,0,0, +1,			  },
169 	  },
170 	  { /*input.*/ { { 0x30FF,0x3092,0x3049,0x0000 },
171 			 { 0x3041,0x308E,0x3049,0x0000 }, },  /* #9 */
172 	    /*expect*/ { 0,0,0, -1,		       },
173 	  },
174 	  { /*input.*/ { { 0x3041,0x308E,0x3049,0x0000 },
175 			 { 0x30FF,0x3092,0x3049,0x0000 }, },  /* #10 */
176 	    /*expect*/ { 0,0,0, +1,		       },
177 	  },
178 	  { .is_last = 1 }
179 	}
180     },
181     {	{ Twcscoll, TST_LOC_end } }
182 };
183