示例#1
0
文件: wctrans.c 项目: Zeke-OS/zeke
int main( void )
{
    TESTCASE(wctrans("") == 0);
    TESTCASE(wctrans("invalid") == 0);
    TESTCASE(wctrans("toupper") != 0);
    TESTCASE(wctrans("tolower") != 0);
    return TEST_RESULTS;
}
示例#2
0
int main( void )
{
    TESTCASE(towctrans(L'a', wctrans("toupper")) == L'A');
    TESTCASE(towctrans(L'B', wctrans("toupper")) == L'B');
    TESTCASE(towctrans(L'a', wctrans("tolower")) == L'a');
    TESTCASE(towctrans(L'B', wctrans("tolower")) == L'b');
    TESTCASE(towctrans(L'B', wctrans("invalid")) == L'B');
    TESTCASE(towctrans(L'B', 0)                  == L'B');
    return TEST_RESULTS;
}
示例#3
0
int
main(int argc, char *argv[])
{
	wctype_t t;
	int i, j;
	struct {
		const char *name;
		wint_t (*func)(wint_t);
	} tran[] = {
		{ "tolower", towlower },
		{ "toupper", towupper },
	};

	printf("1..2\n");

	/*
	 * C/POSIX locale.
	 */
	for (i = 0; i < sizeof(tran) / sizeof(*tran); i++) {
		t = wctrans(tran[i].name);
		assert(t != 0);
		for (j = 0; j < 256; j++)
			assert(tran[i].func(j) == towctrans(j, t));
	}
	t = wctrans("elephant");
	assert(t == 0);
	for (i = 0; i < 256; i++)
		assert(towctrans(i, t) == i);

	/*
	 * Japanese (EUC) locale.
	 */
	assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
	for (i = 0; i < sizeof(tran) / sizeof(*tran); i++) {
		t = wctrans(tran[i].name);
		assert(t != 0);
		for (j = 0; j < 65536; j++)
			assert(tran[i].func(j) == towctrans(j, t));
	}
	t = wctrans("elephant");
	assert(t == 0);
	for (i = 0; i < 65536; i++)
		assert(towctrans(i, t) == i);

	printf("ok 1 - towctrans()\n");
	printf("ok 2 - wctrans()\n");

	return (0);
}
示例#4
0
void runFailure() {
    char buf[] = "";
    //@ assert \valid(buf+(0..\block_length(buf)-1));
    //@ assert \exists integer x; buf[x] == '\0';
    wctrans_t t = wctrans(buf);
    if (t == 0) {return;}

    towctrans(invalid(), t);
}
// -----------------------------------------------------------------------------
//Function Name :testwctrans3
//API Tested :wctrans
//TestCase Description:wctrans returns -> property descriptor if name is valid
//this prop desc can be used by towctrans function to test the wide char passed
//to it is translated to the type returned by the wctrans.(Negative test case).
// -----------------------------------------------------------------------------
TInt CTestLibcwchar::testwctrans3L()
    {
	wctrans_t type;
	  
	type = wctrans("kkkkkwer");
	  
	if(type == (wctrans_t)0)
		{
	  	return KErrNone;
		}
	  
	return KErrGeneral;
	  
    }
示例#6
0
void testValues() {
    f = 2;
    wint_t result;

    char buf[] = "";
    //@ assert \valid(buf+(0..\block_length(buf)-1));
    //@ assert \exists integer x; buf[x] == '\0';
    wctrans_t t = wctrans(buf);
    if (t == 0) {return;}

    towctrans(anychar(), t);

    //@ assert f == 2;
    //@ assert vacuous: \false;
}
示例#7
0
int
main (void)
{
    char buf[30];
    wchar_t wbuf[30];
    wctrans_t t;
    wint_t wch;
    int errors = 0;
    int len;

    setlocale (LC_ALL, "");

    t = wctrans ("test");
    if (t == (wctrans_t) 0)
    {
        puts ("locale data files probably not loaded");
        exit (1);
    }

    wch = towctrans (L'A', t);
    printf ("towctrans (L'A', t) = %c\n", wch);
    if (wch != L'B')
        errors = 1;

    wch = towctrans (L'B', t);
    printf ("towctrans (L'B', t) = %c\n", wch);
    if (wch != L'C')
        errors = 1;

    /* Test the output digit handling.  */
    swprintf (wbuf, sizeof (wbuf) / sizeof (wbuf[0]), L"%Id", 0x499602D2);
    errors |= wcscmp (wbuf, L"bcdefghija") != 0;
    len = wcslen (wbuf);
    errors |= len != 10;
    printf ("len = %d, wbuf = L\"%ls\"\n", len, wbuf);

    snprintf (buf, sizeof buf, "%Id", 0x499602D2);
    errors |= strcmp (buf, "bcdefghija") != 0;
    len = strlen (buf);
    errors |= len != 10;
    printf ("len = %d, buf = \"%s\"\n", len, buf);

    return errors;
}
// -----------------------------------------------------------------------------
//Function Name :testwctrans5
//API Tested :wctrans
//TestCase Description:wctrans returns -> property descriptor if name is valid
//this prop desc can be used by towctrans function to test the wide char passed
// to it is translated to the type returned by the wctrans.
// -----------------------------------------------------------------------------
TInt CTestLibcwchar::testwctrans5L()
    {
	wctrans_t type;
	  
	type = wctrans("toupper");
	  
	if(type == (wctrans_t)0)
		{
	  	return KErrGeneral;
		}
	  
	wint_t twc = towctrans(L'M',type);
	  
	if(twc != L'M')
		{
	  	return KErrGeneral;
		}
	  
	return KErrNone;	
	
    }
// -----------------------------------------------------------------------------
//Function Name :testwctrans4
//API Tested :wctrans
//TestCase Description:wctrans returns -> property descriptor if name is valid
//this prop desc can be used by towctrans function to test the wide char passed
// to it is translated to the type returned by the wctrans.
// -----------------------------------------------------------------------------
TInt CTestLibcwchar::testwctrans4L()
    {
	wctrans_t type;
	  
	type = wctrans("tolower");
	  
	if(type == (wctype_t)0)
		{
	  	return KErrGeneral;
		}
	  
	wint_t twc = towctrans(WEOF,type);
	  
	if(twc != WEOF)
		{
	  	return KErrGeneral;
		}
	  
	return KErrNone;	
	
    }
示例#10
0
// -----------------------------------------------------------------------------
//Function Name :testwctrans1
//API Tested :wctrans
//TestCase Description:wctrans returns -> property descriptor if name is valid
//this prop desc can be used by towctrans function to test the wide char passed
// to it is translated to the type returned by the wctrans.
// -----------------------------------------------------------------------------
TInt CTestLibcwchar::testwctrans1L()
    {
	wctrans_t type;
	  
	type = wctrans("tolower");
	  
	if(type == (wctype_t)0)
		{
	  	return KErrGeneral;
		}
	  
	wint_t twc = towctrans(L'K',type);
	  
	if(twc != (wint_t)L'k')
		{
	  	return KErrGeneral;
		}
	  
	return KErrNone;	
	
    }
示例#11
0
void wctype_check_functions(wint_t i, wctype_t t, wctrans_t tr, locale_t l)
{
    (void)iswalnum(i);
    (void)iswalnum_l(i, l);
    (void)iswalpha(i);
    (void)iswalpha_l(i, l);
    (void)iswblank(i);
    (void)iswblank_l(i, l);
    (void)iswcntrl(i);
    (void)iswcntrl_l(i, l);
    (void)iswctype(i, t);
    (void)iswctype_l(i, t, l);
    (void)iswdigit(i);
    (void)iswdigit_l(i, l);
    (void)iswgraph(i);
    (void)iswgraph_l(i, l);
    (void)iswlower(i);
    (void)iswlower_l(i, l);
    (void)iswprint(i);
    (void)iswprint_l(i, l);
    (void)iswpunct(i);
    (void)iswpunct_l(i, l);
    (void)iswspace(i);
    (void)iswspace_l(i, l);
    (void)iswupper(i);
    (void)iswupper_l(i, l);
    (void)iswxdigit(i);
    (void)iswxdigit_l(i, l);
    (void)towctrans(i, tr);
    (void)towctrans_l(i, tr, l);
    (void)towlower(i);
    (void)towlower_l(i, l);
    (void)towupper(i);
    (void)towupper_l(i, l);
    (void)wctrans((const char *)1234);
    (void)wctrans_l((const char *)1234, l);
    (void)wctype((const char *)1234);
    (void)wctype_l((const char *)1234, l);
}
示例#12
0
/*
 * The extended locale version just calls the regular version.  If there
 * is ever support for arbitrary per-locale translations, this need to
 * be modified.
 */
wctrans_t
wctrans_l(const char *charclass, locale_t loc)
{
	return wctrans(charclass);
}
示例#13
0
wctrans_t wctrans_l(const char* name, locale_t) {
  return wctrans(name);
}
示例#14
0
文件: wctrans_l.c 项目: KGG814/AOS
wctrans_t wctrans_l(const char *s, locale_t l)
{
	return wctrans(s);
}