1 //=================================================================
5 // General testcase for C library multibyte functions
7 //=================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later version.
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 // As a special exception, if other files instantiate templates or use macros
27 // or inline functions from this file, or you compile this file and link it
28 // with other works to produce a work based on this file, this file does not
29 // by itself cause the resulting work to be covered by the GNU General Public
30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 // at http://sources.redhat.com/ecos/ecos-license/
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //=================================================================
41 //#####DESCRIPTIONBEGIN####
43 // Author(s): jjohnstn
46 // Description: Contains general testcode for C library multibyte character functions
49 //####DESCRIPTIONEND####
53 #include <pkgconf/libc_i18n.h> // Configuration header
57 #include <cyg/infra/testcase.h>
63 main( int argc, char *argv[] )
66 #ifdef CYGFUN_LIBC_I18N_LOCALE_C_JIS
67 unsigned char in_jis[] =
68 "abcd\x1b$B\x23\x25\x45\x46\x1b(B23";
69 unsigned char fmt_jis[] =
70 "abcd\x1b$B\x23\x25\x45\x46\x1b(B%d";
72 unsigned char * testjis[] = {
73 "abcd\x1b$B\x23\x25\x45\x46\x1b(B",
74 "abcd\x1b$B\x23\x25\x1b(Befg",
75 "\x1b$B\x23\x7f\x1b(B",
76 "\x1b$B\x44\x45\x46\x1b(B",
82 int mblenjis0[] = { 1, 1, 1, 1, 5, 5, 0};
83 int mblenjis1[] = { 1, 1, 1, 1, 8, 1, 1, 1, 0 };
84 int mblenjis2[] = { -1 };
85 int mblenjis3[] = { 5, -1 };
86 int mblenjis4[] = { -1 };
87 int mblenjis5[] = { -1 };
88 int mblenjis6[] = { -1 };
100 wchar_t mbtowcjis0[] = {
109 #endif /* CYGFUN_LIBC_I18N_LOCALE_C_JIS */
111 #ifdef CYGFUN_LIBC_I18N_LOCALE_C_SJIS
112 unsigned char in_sjis[] =
113 "ab\x81\x40\x9f\x7e\xe0\x80\xef\xfcgh23";
114 unsigned char fmt_sjis[] =
115 "ab\x81\x40\x9f\x7e\xe0\x80\xef\xfcgh%d";
117 unsigned char * testsjis[] = {
118 "ab\x81\x40\x9f\x7e\xe0\x80\xef\xfcgh",
129 int mblensjis0[] = { 1, 1, 2, 2, 2, 2, 1, 1, 0};
130 int mblensjis1[] = { 1, 1, 0 };
131 int mblensjis2[] = { 1, 1, 0 };
132 int mblensjis3[] = { 1, 1, 0 };
133 int mblensjis4[] = { 1, 1, 0 };
134 int mblensjis5[] = { -1 };
135 int mblensjis6[] = { -1 };
136 int mblensjis7[] = { -1 };
137 int mblensjis8[] = { -1 };
151 wchar_t mbtowcsjis0[] = {
162 #endif /* CYGFUN_LIBC_I18N_LOCALE_C_SJIS */
164 #ifdef CYGFUN_LIBC_I18N_LOCALE_C_EUCJP
165 unsigned char in_eucjp[] =
166 "ab\xa1\xa1\xa2\xfe\xe0\xfd\xef\xfcgh23";
167 unsigned char fmt_eucjp[] =
168 "ab\xa1\xa1\xa2\xfe\xe0\xfd\xef\xfcgh%d";
170 unsigned char * testeucjp[] = {
171 "ab\xa1\xa1\xa2\xfe\xe0\xfd\xef\xfcgh",
182 int mbleneucjp0[] = { 1, 1, 2, 2, 2, 2, 1, 1, 0};
183 int mbleneucjp1[] = { 1, -1 };
184 int mbleneucjp2[] = { 1, -1 };
185 int mbleneucjp3[] = { 1, -1 };
186 int mbleneucjp4[] = { 1, -1 };
187 int mbleneucjp5[] = { -1 };
188 int mbleneucjp6[] = { -1 };
189 int mbleneucjp7[] = { -1 };
190 int mbleneucjp8[] = { -1 };
192 int *mbleneucjp[] = {
204 wchar_t mbtowceucjp0[] = {
215 #endif /* CYGFUN_LIBC_I18N_LOCALE_C_EUCJP */
224 k=0; locale=NULL; // silence warnings
228 CYG_TEST_INFO( "Starting tests from testcase " __FILE__ " for C library "
229 "<stdlib.h> multi-byte character functions" );
231 setlocale (LC_ALL, "C");
233 CYG_TEST_PASS_FAIL( MB_CUR_MAX == 1, "MB_CUR_MAX");
235 CYG_TEST_PASS_FAIL( mblen(NULL, 0) == 0, "mblen(NULL, 0)");
237 CYG_TEST_PASS_FAIL( mbtowc(NULL, NULL, 0) == 0, "mbtowc(NULL, NULL, 0)");
239 CYG_TEST_PASS_FAIL( wctomb(NULL, 0) == 0, "wctomb(NULL, 0)");
241 ptr = "abcdefghijklmnop";
246 result = mblen (ptr, MB_CUR_MAX);
251 CYG_TEST_PASS_FAIL( result == 0, "mblen (ptr, MB_CUR_MAX)");
252 CYG_TEST_PASS_FAIL( j == strlen("abcdefghijklmnop") + 1, "j");
256 memset(wcbuff, 'K', 40);
260 result = mbtowc (wcptr, ptr, MB_CUR_MAX);
261 CYG_TEST_PASS_FAIL( *wcptr == (wchar_t)*ptr, "*wcptr");
267 CYG_TEST_PASS_FAIL( wcptr - wcbuff == 11, "wcptr - wcbuff");
268 CYG_TEST_PASS_FAIL( wcbuff[10] == 0, "wcbuff[10]");
270 memset (buff, 'K', 40);
275 for (i = 0; i < 11; ++i)
277 result = wctomb (ptr, *wcptr);
282 CYG_TEST_PASS_FAIL( strcmp("1234567890", buff) == 0, "strcmp(\"1234567890\", buff");
284 memset (wcbuff, 'K', 40);
285 result = mbstowcs (wcbuff, "abcdef", 7);
286 CYG_TEST_PASS_FAIL( result == 6, "mbstowcs (wcbuff, \"abcdef\", 7)");
287 CYG_TEST_PASS_FAIL(*((char *)(&wcbuff[7])) == 'K', "*((char *)(&wcbuff[7]))");
288 CYG_TEST_PASS_FAIL( wcbuff[6] == 0, "wcbuff[6]");
290 memset(buff, 'K', 20);
291 result = wcstombs (buff, wcbuff, 20);
292 CYG_TEST_PASS_FAIL( result == 6, "wcstombs (buff, wcbuff, 20)");
293 CYG_TEST_PASS_FAIL( strcmp(buff, "abcdef") == 0, "strcmp(buff, \"abcdef\")");
295 #ifdef CYGFUN_LIBC_I18N_LOCALE_C_JIS
297 CYG_TEST_INFO( "Testing C-JIS locale" );
299 locale = setlocale (LC_CTYPE, "C-JIS");
300 CYG_TEST_PASS_FAIL( locale != NULL, "setlocale (LC_CTYPE, \"C-JIS\")");
302 CYG_TEST_PASS_FAIL( strcmp(locale, "C-JIS") == 0, "strcmp(locale, \"C-JIS\")");
304 locale = setlocale (LC_CTYPE, NULL);
305 CYG_TEST_PASS_FAIL( strcmp(locale, "C-JIS") == 0, "setlocale(LC_CTYPE, NULL)");
307 CYG_TEST_PASS_FAIL( MB_CUR_MAX == 8, "MB_CUR_MAX");
309 CYG_TEST_PASS_FAIL( mblen(NULL, 0) != 0, "mblen(NULL, 0)");
311 CYG_TEST_PASS_FAIL( mbtowc(NULL, NULL, 0) != 0, "mbtowc(NULL, NULL, 0)");
313 CYG_TEST_PASS_FAIL( wctomb(NULL, 0) != 0, "wctomb(NULL, 0)");
315 for (i = 0; i < sizeof(testjis) / sizeof(char *); ++i)
322 result = mblen (ptr, MB_CUR_MAX);
323 CYG_TEST_PASS_FAIL( result == mblenjis[i][j], "mblen (ptr, MB_CUR_MAX)");
331 memset(wcbuff, 'K', 40);
336 result = mbtowc (wcptr, ptr, MB_CUR_MAX);
337 CYG_TEST_PASS_FAIL( result == mblenjis0[j], "mbtowc (wcptr, ptr, MB_CUR_MAX)");
338 CYG_TEST_PASS_FAIL( *wcptr == mbtowcjis0[j], "*wcptr");
344 CYG_TEST_PASS_FAIL( wcptr - wcbuff == 7, "wcptr - wcbuff");
345 CYG_TEST_PASS_FAIL( wcbuff[6] == 0, "wcbuff[6]");
347 memset (buff, 'K', 40);
352 for (i = 0; i < 7; ++i)
354 result = wctomb (ptr, *wcptr);
359 CYG_TEST_PASS_FAIL( strcmp(testjis[0], buff) == 0, "strcmp(testjis[0], buff");
361 result = wctomb (buff, (wchar_t)0x1111);
362 CYG_TEST_PASS_FAIL( result == -1, "wctomb(buff, (wchar_t)0x1111)");
364 result = mbstowcs (wcbuff, testjis[3], 8);
365 CYG_TEST_PASS_FAIL( result == -1, "mbstowcs(wcbuff, testjis[3], 8)");
367 memset (wcbuff, 'K', 40);
368 result = mbstowcs (wcbuff, testjis[0], 8);
369 CYG_TEST_PASS_FAIL( result == 6, "mbstowcs(wcbuff, testjis[0], 8)");
370 CYG_TEST_PASS_FAIL( *((char *)(&wcbuff[7])) == 'K', "*((char *)(&wcbuff[7]))");
371 CYG_TEST_PASS_FAIL( wcbuff[6] == 0, "wcbuff[6]");
373 memset (wcbuff, 'K', 40);
374 result = mbstowcs (wcbuff, testjis[0], 6);
375 CYG_TEST_PASS_FAIL( result == 6, "mbstowcs (wcbuff, testjis[0], 6)");
376 CYG_TEST_PASS_FAIL( *((char *)(&wcbuff[6])) == 'K', "*((char *)(&wcbuff[6]))");
378 memset (wcbuff, 'K', 40);
379 result = mbstowcs (wcbuff, testjis[0], 7);
380 CYG_TEST_PASS_FAIL( result == 6, "mbstowcs (wcbuff, testjis[0], 7)");
381 CYG_TEST_PASS_FAIL(*((char *)(&wcbuff[7])) == 'K', "*((char *)(&wcbuff[7]))");
382 CYG_TEST_PASS_FAIL( wcbuff[6] == 0, "wcbuff[6]");
384 memset(buff, 'K', 20);
385 result = wcstombs (buff, wcbuff, 20);
386 CYG_TEST_PASS_FAIL( result == 14, "wcstombs (buff, wcbuff, 20)");
387 CYG_TEST_PASS_FAIL( strcmp(buff, testjis[0]) == 0, "strcmp(buff, testjis[0])");
389 memset (buff, 'K', 20);
390 result = wcstombs (buff, wcbuff, 14);
391 CYG_TEST_PASS_FAIL( result == 14, "wcstombs (buff, wcbuff, 14)");
392 CYG_TEST_PASS_FAIL( memcmp (buff, testjis[0], 14) == 0, "memcmp (buff, testjis[0], 14)");
393 CYG_TEST_PASS_FAIL( buff[14] == 'K', "buff[14]");
395 memset (buff, 'K', 20);
396 result = wcstombs (buff, wcbuff, 15);
397 CYG_TEST_PASS_FAIL( result == 14, "wcstombs (buff, wcbuff, 15)");
398 CYG_TEST_PASS_FAIL( memcmp (buff, testjis[0], 14) == 0, "memcmp (buff, testjis[0], 14)");
399 CYG_TEST_PASS_FAIL( buff[14] == '\0', "buff[14]");
401 result = wcstombs (buff, (wchar_t *)"\x23\x10", 2);
402 CYG_TEST_PASS_FAIL( result == -1, "wcstombs (buff, (wchar_t *)\"\x23\x10\", 2)");
404 result = sscanf (in_jis, fmt_jis, &k);
405 CYG_TEST_PASS_FAIL( result == 1, "sscanf (in_jis, fmt_jis, &k)");
406 CYG_TEST_PASS_FAIL( k == 23, "k");
408 sprintf (buff, fmt_jis, 23);
409 CYG_TEST_PASS_FAIL( strcmp(buff, in_jis) == 0, "sprintf(buff, fmt_jis, 23)");
411 locale = setlocale(LC_ALL, "C");
412 locale = setlocale(LC_CTYPE, NULL);
414 CYG_TEST_PASS_FAIL( strcmp(locale, "C") == 0, "previous locale");
415 CYG_TEST_PASS_FAIL( MB_CUR_MAX == 1, "MB_CUR_MAX");
417 #endif /* CYGFUN_LIBC_I18N_LOCALE_C_JIS */
419 #ifdef CYGFUN_LIBC_I18N_LOCALE_C_SJIS
421 CYG_TEST_INFO( "Testing C-SJIS locale" );
423 locale = setlocale (LC_CTYPE, "C-SJIS");
424 CYG_TEST_PASS_FAIL( locale != NULL, "setlocale (LC_CTYPE, \"C-SJIS\")");
426 CYG_TEST_PASS_FAIL( strcmp(locale, "C-SJIS") == 0, "setlocale(LC_CTYPE, \"C-SJIS\")");
428 locale = setlocale (LC_CTYPE, NULL);
429 CYG_TEST_PASS_FAIL( strcmp(locale, "C-SJIS") == 0, "setlocale(LC_CTYPE, NULL)");
431 CYG_TEST_PASS_FAIL( MB_CUR_MAX == 2, "MB_CUR_MAX");
433 CYG_TEST_PASS_FAIL( mblen(NULL, 0) == 0, "mblen(NULL, 0)");
435 CYG_TEST_PASS_FAIL( mbtowc(NULL, NULL, 0) == 0, "mbtowc(NULL, NULL, 0)");
437 CYG_TEST_PASS_FAIL( wctomb(NULL, 0) == 0, "wctomb(NULL, 0)");
439 for (i = 0; i < sizeof(testsjis) / sizeof(char *); ++i)
446 result = mblen (ptr, MB_CUR_MAX);
447 CYG_TEST_PASS_FAIL( result == mblensjis[i][j], "mblen (ptr, MB_CUR_MAX)");
455 memset(wcbuff, 'K', 40);
460 result = mbtowc (wcptr, ptr, MB_CUR_MAX);
461 CYG_TEST_PASS_FAIL( result == mblensjis0[j], "mbtowc (wcptr, ptr, MB_CUR_MAX)");
462 CYG_TEST_PASS_FAIL( *wcptr == mbtowcsjis0[j], "*wcptr");
468 CYG_TEST_PASS_FAIL( wcptr - wcbuff == 9, "wcptr - wcbuff");
469 CYG_TEST_PASS_FAIL( wcbuff[8] == 0, "wcbuff[8]");
471 memset (buff, 'K', 40);
476 for (i = 0; i < 9; ++i)
478 result = wctomb (ptr, *wcptr);
483 CYG_TEST_PASS_FAIL( strcmp(testsjis[0], buff) == 0, "strcmp(testsjis[0], buff");
485 result = wctomb (buff, (wchar_t)0x1111);
486 CYG_TEST_PASS_FAIL( result == -1, "wctomb(buff, (wchar_t)0x1111)");
488 result = mbstowcs (wcbuff, testsjis[5], 8);
489 CYG_TEST_PASS_FAIL( result == -1, "mbstowcs(wcbuff, testjis[3], 8)");
491 memset (wcbuff, 'K', 40);
492 result = mbstowcs (wcbuff, testsjis[0], 20);
493 CYG_TEST_PASS_FAIL( result == 8, "mbstowcs(wcbuff, testsjis[0], 20)");
494 CYG_TEST_PASS_FAIL( *((char *)(&wcbuff[9])) == 'K', "*((char *)(&wcbuff[9]))");
495 CYG_TEST_PASS_FAIL( wcbuff[8] == 0, "wcbuff[8]");
497 memset (wcbuff, 'K', 40);
498 result = mbstowcs (wcbuff, testsjis[0], 8);
499 CYG_TEST_PASS_FAIL( result == 8, "mbstowcs (wcbuff, testsjis[0], 8)");
500 CYG_TEST_PASS_FAIL( *((char *)(&wcbuff[8])) == 'K', "*((char *)(&wcbuff[8]))");
502 memset (wcbuff, 'K', 40);
503 result = mbstowcs (wcbuff, testsjis[0], 9);
504 CYG_TEST_PASS_FAIL( result == 8, "mbstowcs (wcbuff, testsjis[0], 9)");
505 CYG_TEST_PASS_FAIL(*((char *)(&wcbuff[9])) == 'K', "*((char *)(&wcbuff[9]))");
506 CYG_TEST_PASS_FAIL( wcbuff[8] == 0, "wcbuff[8]");
508 memset(buff, 'K', 20);
509 result = wcstombs (buff, wcbuff, 20);
510 CYG_TEST_PASS_FAIL( result == 12, "wcstombs (buff, wcbuff, 20)");
511 CYG_TEST_PASS_FAIL( strcmp(buff, testsjis[0]) == 0, "strcmp(buff, testjis[0])");
513 memset (buff, 'K', 20);
514 result = wcstombs (buff, wcbuff, 12);
515 CYG_TEST_PASS_FAIL( result == 12, "wcstombs (buff, wcbuff, 12)");
516 CYG_TEST_PASS_FAIL( memcmp (buff, testsjis[0], 12) == 0, "memcmp (buff, testsjis[0], 12)");
517 CYG_TEST_PASS_FAIL( buff[12] == 'K', "buff[12]");
519 memset (buff, 'K', 20);
520 result = wcstombs (buff, wcbuff, 13);
521 CYG_TEST_PASS_FAIL( result == 12, "wcstombs (buff, wcbuff, 12)");
522 CYG_TEST_PASS_FAIL( memcmp (buff, testsjis[0], 13) == 0, "memcmp (buff, testsjis[0], 13)");
523 CYG_TEST_PASS_FAIL( buff[12] == '\0', "buff[12]");
525 result = wcstombs (buff, (wchar_t *)"\x23\x10", 2);
526 CYG_TEST_PASS_FAIL( result == -1, "wcstombs (buff, (wchar_t *)\"\x23\x10\", 2)");
528 result = sscanf (in_sjis, fmt_sjis, &k);
529 CYG_TEST_PASS_FAIL( result == 1, "sscanf (in_sjis, fmt_sjis, &k)");
530 CYG_TEST_PASS_FAIL( k == 23, "k");
532 sprintf (buff, fmt_sjis, 23);
533 CYG_TEST_PASS_FAIL( strcmp(buff, in_sjis) == 0, "sprintf(buff, fmt_sjis, 23)");
535 locale = setlocale(LC_ALL, "C");
536 locale = setlocale(LC_CTYPE, NULL);
538 CYG_TEST_PASS_FAIL( strcmp(locale, "C") == 0, "previous locale");
539 CYG_TEST_PASS_FAIL( MB_CUR_MAX == 1, "MB_CUR_MAX");
541 #endif /* CYGFUN_LIBC_I18N_LOCALE_C_SJIS */
543 #ifdef CYGFUN_LIBC_I18N_LOCALE_C_EUCJP
545 CYG_TEST_INFO( "Testing C-EUCJP locale" );
547 locale = setlocale (LC_CTYPE, "C-EUCJP");
548 CYG_TEST_PASS_FAIL( locale != NULL, "setlocale (LC_CTYPE, \"C-EUCJP\")");
550 CYG_TEST_PASS_FAIL( strcmp(locale, "C-EUCJP") == 0, "setlocale(LC_CTYPE, \"C-EUCJP\")");
552 locale = setlocale (LC_CTYPE, NULL);
553 CYG_TEST_PASS_FAIL( strcmp(locale, "C-EUCJP") == 0, "current locale");
555 CYG_TEST_PASS_FAIL( MB_CUR_MAX == 2, "MB_CUR_MAX");
557 CYG_TEST_PASS_FAIL( mblen(NULL, 0) == 0, "mblen(NULL, 0)");
559 CYG_TEST_PASS_FAIL( mbtowc(NULL, NULL, 0) == 0, "mbtowc(NULL, NULL, 0)");
561 CYG_TEST_PASS_FAIL( wctomb(NULL, 0) == 0, "wctomb(NULL, 0)");
563 for (i = 0; i < sizeof(testeucjp) / sizeof(char *); ++i)
570 result = mblen (ptr, MB_CUR_MAX);
571 CYG_TEST_PASS_FAIL( result == mbleneucjp[i][j], "mblen (ptr, MB_CUR_MAX)");
579 memset(wcbuff, 'K', 40);
584 result = mbtowc (wcptr, ptr, MB_CUR_MAX);
585 CYG_TEST_PASS_FAIL( result == mbleneucjp0[j], "mbtowc (wcptr, ptr, MB_CUR_MAX)");
586 CYG_TEST_PASS_FAIL( *wcptr == mbtowceucjp0[j], "*wcptr");
592 CYG_TEST_PASS_FAIL( wcptr - wcbuff == 9, "wcptr - wcbuff");
593 CYG_TEST_PASS_FAIL( wcbuff[8] == 0, "wcbuff[8]");
595 memset (buff, 'K', 40);
600 for (i = 0; i < 9; ++i)
602 result = wctomb (ptr, *wcptr);
607 CYG_TEST_PASS_FAIL( strcmp(testeucjp[0], buff) == 0, "strcmp(testeucjp[0], buff");
609 result = wctomb (buff, (wchar_t)0x1111);
610 CYG_TEST_PASS_FAIL( result == -1, "wctomb(buff, (wchar_t)0x1111)");
612 result = mbstowcs (wcbuff, testeucjp[5], 8);
613 CYG_TEST_PASS_FAIL( result == -1, "mbstowcs(wcbuff, testjis[3], 8)");
615 memset (wcbuff, 'K', 40);
616 result = mbstowcs (wcbuff, testeucjp[0], 20);
617 CYG_TEST_PASS_FAIL( result == 8, "mbstowcs(wcbuff, testeucjp[0], 20)");
618 CYG_TEST_PASS_FAIL( *((char *)(&wcbuff[9])) == 'K', "*((char *)(&wcbuff[9]))");
619 CYG_TEST_PASS_FAIL( wcbuff[8] == 0, "wcbuff[8]");
621 memset (wcbuff, 'K', 40);
622 result = mbstowcs (wcbuff, testeucjp[0], 8);
623 CYG_TEST_PASS_FAIL( result == 8, "mbstowcs (wcbuff, testeucjp[0], 8)");
624 CYG_TEST_PASS_FAIL( *((char *)(&wcbuff[8])) == 'K', "*((char *)(&wcbuff[8]))");
626 memset (wcbuff, 'K', 40);
627 result = mbstowcs (wcbuff, testeucjp[0], 9);
628 CYG_TEST_PASS_FAIL( result == 8, "mbstowcs (wcbuff, testeucjp[0], 9)");
629 CYG_TEST_PASS_FAIL(*((char *)(&wcbuff[9])) == 'K', "*((char *)(&wcbuff[9]))");
630 CYG_TEST_PASS_FAIL( wcbuff[8] == 0, "wcbuff[8]");
632 memset(buff, 'K', 20);
633 result = wcstombs (buff, wcbuff, 20);
634 CYG_TEST_PASS_FAIL( result == 12, "wcstombs (buff, wcbuff, 20)");
635 CYG_TEST_PASS_FAIL( strcmp(buff, testeucjp[0]) == 0, "strcmp(buff, testjis[0])");
637 memset (buff, 'K', 20);
638 result = wcstombs (buff, wcbuff, 12);
639 CYG_TEST_PASS_FAIL( result == 12, "wcstombs (buff, wcbuff, 12)");
640 CYG_TEST_PASS_FAIL( memcmp (buff, testeucjp[0], 12) == 0, "memcmp (buff, testeucjp[0], 12)");
641 CYG_TEST_PASS_FAIL( buff[12] == 'K', "buff[12]");
643 memset (buff, 'K', 20);
644 result = wcstombs (buff, wcbuff, 13);
645 CYG_TEST_PASS_FAIL( result == 12, "wcstombs (buff, wcbuff, 12)");
646 CYG_TEST_PASS_FAIL( memcmp (buff, testeucjp[0], 13) == 0, "memcmp (buff, testeucjp[0], 13)");
647 CYG_TEST_PASS_FAIL( buff[12] == '\0', "buff[12]");
649 result = wcstombs (buff, (wchar_t *)"\x23\x10", 2);
650 CYG_TEST_PASS_FAIL( result == -1, "wcstombs (buff, (wchar_t *)\"\x23\x10\", 2)");
652 result = sscanf (in_eucjp, fmt_eucjp, &k);
653 CYG_TEST_PASS_FAIL( result == 1, "sscanf (in_eucjp, fmt_eucjp, &k)");
654 CYG_TEST_PASS_FAIL( k == 23, "k");
656 sprintf (buff, fmt_eucjp, 23);
657 CYG_TEST_PASS_FAIL( strcmp(buff, in_eucjp) == 0, "sprintf(buff, fmt_eucjp, 23)");
659 locale = setlocale(LC_ALL, "C");
660 locale = setlocale(LC_CTYPE, NULL);
662 CYG_TEST_PASS_FAIL( strcmp(locale, "C") == 0, "previous locale");
663 CYG_TEST_PASS_FAIL( MB_CUR_MAX == 1, "MB_CUR_MAX");
665 #endif /* CYGFUN_LIBC_I18N_LOCALE_C_EUCJP */
668 CYG_TEST_FINISH( "Finished tests from testcase " __FILE__ " for C library "
669 "<stdlib.h> multibyte character functions" );