1 /*
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 
56 TST_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   {
111     { Twctomb, TST_LOC_eucJP },
112     {
113       /* #01 : normal case		   */
114       { /*input.*/ { 1,	   0x3042  },
115 	/*expect*/ { 0,1,2,  "\244\242"   },
116       },
117       /* #02 : normal case		   */
118       { /*input.*/ { 1,	   0x3044  },
119 	/*expect*/ { 0,1,2,  "\244\244"   },
120       },
121       /* #03 : normal case		   */
122       { /*input.*/ { 1,	   0x008E  },
123 	/*expect*/ { 0,1,-1, ""	   },
124       },
125       /* #04 : jisX0212		   */
126       { /*input.*/ { 1,	   0x00C4	  },
127 	/*expect*/ { 0,1,3,  "\217\252\243" }, /* jisx0210  returns 3 */
128       },
129       /* #05 : state dependency	   */
130       { /*input.*/ { 0,	   0x008E  },
131 	/*expect*/ { 0,0,0,  ""	   },
132       },
133       { .is_last = 1 }
134     }
135   },
136   {
137     { Twctomb, TST_LOC_end }
138   }
139 };
140