Add test cases for btowc() and wctob() in multibyte locales.

This commit is contained in:
Tim J. Robbins 2002-11-10 11:03:32 +00:00
parent 99eabcc8c3
commit 85fafcf803

View file

@ -28,7 +28,7 @@
* Test program for btowc() and wctob() as specified by IEEE Std. 1003.1-2001
* and ISO/IEC 9899:1999.
*
* The function is tested in only the "C" locale.
* The function is tested in the "C" and "ja_JP.eucJP" locales.
*/
#include <sys/cdefs.h>
@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <assert.h>
#include <limits.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
@ -45,11 +46,23 @@ main(int argc, char *argv[])
{
int i;
/*
* C/POSIX locale.
*/
assert(btowc(EOF) == WEOF);
assert(wctob(WEOF) == EOF);
for (i = 0; i < UCHAR_MAX; i++)
assert(btowc(i) == (wchar_t)i && i == (int)wctob(i));
/*
* Japanese (EUC) locale.
*/
assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
assert(MB_CUR_MAX > 1);
assert(btowc('A') == L'A' && wctob(L'A') == 'A');
assert(btowc(0xa3) == WEOF && wctob(0xa3c1) == EOF);
printf("PASS btowc()\n");
printf("PASS wctob()\n");