diff options
author | Tim Schumacher <timschumi@gmx.de> | 2021-09-17 18:28:28 +0200 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-09-17 22:59:51 +0000 |
commit | 8c7b566629e3f8706580a73cc8da152879c9f9ef (patch) | |
tree | 186606251cd2d01c7672c594096af9696492f535 /Tests | |
parent | ff0ab8b9a96ab784d9cd077b5f8e105492e55b9b (diff) | |
download | serenity-8c7b566629e3f8706580a73cc8da152879c9f9ef.zip |
LibC: Implement iswctype
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/LibC/TestWctype.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Tests/LibC/TestWctype.cpp b/Tests/LibC/TestWctype.cpp index 401ce66635..ed1d7d0028 100644 --- a/Tests/LibC/TestWctype.cpp +++ b/Tests/LibC/TestWctype.cpp @@ -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); + } +} |