Linux: Assume and consolidate bind wire-up syscall
[glibc.git] / localedata / tests-mbwc / dat_wctomb.c
blob7394ca530bd3abf5dcddae37737d34274a0544fe
1 /*
2 * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
4 * FILE: dat_wctomb.c
6 * WCTOMB: int wctomb (char *s, wchar_t wc)
7 */
11 * FUNCTION:
13 * int wctomb (char *s, wchar_t wc);
15 * return: the number of bytes
17 * NOTE:
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 "".
23 * o When s is a null pointer, the function checks state dependency.
25 * state-dependent encoding - return NON-zero
26 * state-independent encoding - return 0
28 * If state-dependent encoding is expected, set
30 * s_flg = 0, ret_flg = 0, ret_val = +1
32 * If state-independent encoding is expected, set
34 * s_flg = 0, ret_flg = 0, ret_val = 0
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.
45 * Input Expect
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)
56 TST_WCTOMB tst_wctomb_loc [] = {
58 { Twctomb, TST_LOC_de },
60 /* #01 : normal case */
61 { /*input.*/ { 1, 0x00C4 },
62 /*expect*/ { 0,1,1, "Ä" },
64 /* #02 : normal case */
65 { /*input.*/ { 1, 0x00DC },
66 /*expect*/ { 0,1,1, "Ü" },
68 /* #03 : normal case */
69 { /*input.*/ { 1, 0x0092 },
70 /*expect*/ { 0,1,1, "\222" },
72 /* #04 : error case */
73 { /*input.*/ { 1, 0x3041 },
74 /*expect*/ { 0,1,-1, "" },
76 /* #05 : state dependency */
77 { /*input.*/ { 0, 0x0000 },
78 /*expect*/ { 0,0,0, "" },
80 { .is_last = 1 }
84 { Twctomb, TST_LOC_enUS },
86 /* #01 : normal case */
87 { /*input.*/ { 1, 0x0041 },
88 /*expect*/ { 0,1,1, "A" },
90 /* #02 : normal case */
91 { /*input.*/ { 1, 0x0042 },
92 /*expect*/ { 0,1,1, "B" },
94 /* #03 : error case */
95 /* <WAIVER> */
96 { /*input.*/ { 1, 0x00C4 },
97 /*expect*/ { 0,1,-1, "" },
99 /* #04 : error case */
100 { /*input.*/ { 1, 0x30A4 },
101 /*expect*/ { 0,1,-1, "" },
103 /* #05 : state dependency */
104 { /*input.*/ { 0, 0x0000 },
105 /*expect*/ { 0,0,0, "" },
107 { .is_last = 1 }
111 { Twctomb, TST_LOC_eucJP },
113 /* #01 : normal case */
114 { /*input.*/ { 1, 0x3042 },
115 /*expect*/ { 0,1,2, "\244\242" },
117 /* #02 : normal case */
118 { /*input.*/ { 1, 0x3044 },
119 /*expect*/ { 0,1,2, "\244\244" },
121 /* #03 : normal case */
122 { /*input.*/ { 1, 0x008E },
123 /*expect*/ { 0,1,-1, "" },
125 /* #04 : jisX0212 */
126 { /*input.*/ { 1, 0x00C4 },
127 /*expect*/ { 0,1,3, "\217\252\243" }, /* jisx0210 returns 3 */
129 /* #05 : state dependency */
130 { /*input.*/ { 0, 0x008E },
131 /*expect*/ { 0,0,0, "" },
133 { .is_last = 1 }
137 { Twctomb, TST_LOC_end }