mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:07:46 +00:00
LibC: Implement iswctype
This commit is contained in:
parent
ff0ab8b9a9
commit
8c7b566629
2 changed files with 68 additions and 3 deletions
|
@ -39,3 +39,30 @@ TEST_CASE(wctrans)
|
|||
EXPECT(wctrans("") == 0);
|
||||
EXPECT(wctrans("abc") == 0);
|
||||
}
|
||||
|
||||
TEST_CASE(iswctype)
|
||||
{
|
||||
const wint_t test_chars[] = { L'A', L'a', L'F', L'f', L'Z', L'z', L'0', L'\n', L'.', L'\x00' };
|
||||
|
||||
// Test that valid properties are wired to the correct implementation.
|
||||
for (unsigned int i = 0; i < sizeof(test_chars) / sizeof(test_chars[0]); i++) {
|
||||
EXPECT(iswctype(test_chars[i], wctype("alnum")) == iswalnum(test_chars[i]));
|
||||
EXPECT(iswctype(test_chars[i], wctype("alpha")) == iswalpha(test_chars[i]));
|
||||
EXPECT(iswctype(test_chars[i], wctype("blank")) == iswblank(test_chars[i]));
|
||||
EXPECT(iswctype(test_chars[i], wctype("cntrl")) == iswcntrl(test_chars[i]));
|
||||
EXPECT(iswctype(test_chars[i], wctype("digit")) == iswdigit(test_chars[i]));
|
||||
EXPECT(iswctype(test_chars[i], wctype("graph")) == iswgraph(test_chars[i]));
|
||||
EXPECT(iswctype(test_chars[i], wctype("lower")) == iswlower(test_chars[i]));
|
||||
EXPECT(iswctype(test_chars[i], wctype("print")) == iswprint(test_chars[i]));
|
||||
EXPECT(iswctype(test_chars[i], wctype("punct")) == iswpunct(test_chars[i]));
|
||||
EXPECT(iswctype(test_chars[i], wctype("space")) == iswspace(test_chars[i]));
|
||||
EXPECT(iswctype(test_chars[i], wctype("upper")) == iswupper(test_chars[i]));
|
||||
EXPECT(iswctype(test_chars[i], wctype("xdigit")) == iswxdigit(test_chars[i]));
|
||||
}
|
||||
|
||||
// Test that invalid properties always return zero.
|
||||
for (unsigned int i = 0; i < sizeof(test_chars) / sizeof(test_chars[0]); i++) {
|
||||
EXPECT(iswctype(test_chars[i], 0) == 0);
|
||||
EXPECT(iswctype(test_chars[i], -1) == 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue