blob: 0ec3a9c0d065b00c902833b5754e781303a9a5ad [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
3 *
4 * FILE: dat_wctomb.c
5 *
6 * WCTOMB: int wctomb (char *s, wchar_t wc)
7 */
8
9
10/*
11 * FUNCTION:
12 *
13 * int wctomb (char *s, wchar_t wc);
14 *
15 * return: the number of bytes
16 *
17 * NOTE:
18 *
19 * o When you feed a null pointer for a string (s) to the function,
20 * set s_flg=0 instead of putting just a 'NULL' there.
21 * Even if you put a 'NULL', it means a null string as well as "".
22 *
23 * o When s is a null pointer, the function checks state dependency.
24 *
25 * state-dependent encoding - return NON-zero
26 * state-independent encoding - return 0
27 *
28 * If state-dependent encoding is expected, set
29 *
30 * s_flg = 0, ret_flg = 0, ret_val = +1
31 *
32 * If state-independent encoding is expected, set
33 *
34 * s_flg = 0, ret_flg = 0, ret_val = 0
35 *
36 *
37 * When you set ret_flg=1, the test program simply compares an
38 * actual return value with an expected value. You can check
39 * state-independent case (return value is 0) in that way, but
40 * you can not check state-dependent case. So when you check
41 * state- dependency in this test function: tst_wctomb(), set
42 * ret_flg=0 always. It's a special case, and the test
43 * function takes care of it.
44 *
45 * Input Expect
46 *
47 * s_flg=0 ret_flg=0
48 * | |
49 * { 0, 0 }, { 0, 0, 0, x, "" }
50 * | |
51 * not used ret_val: 0/+1
52 * (expected val)
53 */
54
55
56TST_WCTOMB tst_wctomb_loc [] = {
57 {
58 { Twctomb, TST_LOC_de },
59 {
60 /* #01 : normal case */
61 { /*input.*/ { 1, 0x00C4 },
62 /*expect*/ { 0,1,1, "Ä" },
63 },
64 /* #02 : normal case */
65 { /*input.*/ { 1, 0x00DC },
66 /*expect*/ { 0,1,1, "Ü" },
67 },
68 /* #03 : normal case */
69 { /*input.*/ { 1, 0x0092 },
70 /*expect*/ { 0,1,1, "\222" },
71 },
72 /* #04 : error case */
73 { /*input.*/ { 1, 0x3041 },
74 /*expect*/ { 0,1,-1, "" },
75 },
76 /* #05 : state dependency */
77 { /*input.*/ { 0, 0x0000 },
78 /*expect*/ { 0,0,0, "" },
79 },
80 { .is_last = 1 }
81 }
82 },
83 {
84 { Twctomb, TST_LOC_enUS },
85 {
86 /* #01 : normal case */
87 { /*input.*/ { 1, 0x0041 },
88 /*expect*/ { 0,1,1, "A" },
89 },
90 /* #02 : normal case */
91 { /*input.*/ { 1, 0x0042 },
92 /*expect*/ { 0,1,1, "B" },
93 },
94 /* #03 : error case */
95 /* <WAIVER> */
96 { /*input.*/ { 1, 0x00C4 },
97 /*expect*/ { 0,1,-1, "" },
98 },
99 /* #04 : error case */
100 { /*input.*/ { 1, 0x30A4 },
101 /*expect*/ { 0,1,-1, "" },
102 },
103 /* #05 : state dependency */
104 { /*input.*/ { 0, 0x0000 },
105 /*expect*/ { 0,0,0, "" },
106 },
107 { .is_last = 1 }
108 }
109 },
110#if 0
111 {
112 { Twctomb, TST_LOC_eucJP },
113 {
114 /* #01 : normal case */
115 { /*input.*/ { 1, 0x3042 },
116 /*expect*/ { 0,1,2, "\244\242" },
117 },
118 /* #02 : normal case */
119 { /*input.*/ { 1, 0x3044 },
120 /*expect*/ { 0,1,2, "\244\244" },
121 },
122 /* #03 : normal case */
123 { /*input.*/ { 1, 0x008E },
124 /*expect*/ { 0,1,-1, "" },
125 },
126 /* #04 : jisX0212 */
127 { /*input.*/ { 1, 0x00C4 },
128 /*expect*/ { 0,1,3, "\217\252\243" }, /* jisx0210 returns 3 */
129 },
130 /* #05 : state dependency */
131 { /*input.*/ { 0, 0x008E },
132 /*expect*/ { 0,0,0, "" },
133 },
134 { .is_last = 1 }
135 }
136 },
137#else
138 {
139 { Twctomb, TST_LOC_ja_UTF8 },
140 {
141 /* #01 : normal case */
142 { /*input.*/ { 1, 0x3042 },
143 /*expect*/ { 0,1,3, "\343\201\202" },
144 },
145 /* #02 : normal case */
146 { /*input.*/ { 1, 0x3044 },
147 /*expect*/ { 0,1,3, "\343\201\204" },
148 },
149 /* #03 : normal case */
150 { /*input.*/ { 1, 0x008E },
151 /*expect*/ { 0,1,2, "\302\216" },
152 },
153 /* #04 : jisX0212 */
154 { /*input.*/ { 1, 0x00C4 },
155 /*expect*/ { 0,1,2, "\303\204" }, /* jisx0210 returns 3 */
156 },
157 /* #05 : state dependency */
158 { /*input.*/ { 0, 0x008E },
159 /*expect*/ { 0,0,0, "" },
160 },
161 { .is_last = 1 }
162 }
163 },
164#endif
165 {
166 { Twctomb, TST_LOC_end }
167 }
168};