diff options
author | Tim Schumacher <timschumi@gmx.de> | 2021-09-17 18:30:25 +0200 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-09-17 22:59:51 +0000 |
commit | 42031f026a06e4aa3b9bbfca8cfe451a6e0f1e4a (patch) | |
tree | c26242164b9e88470cd62803fee11a46f36307cb /Tests | |
parent | 8c7b566629e3f8706580a73cc8da152879c9f9ef (diff) | |
download | serenity-42031f026a06e4aa3b9bbfca8cfe451a6e0f1e4a.zip |
LibC: Implement towctrans
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/LibC/TestWctype.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Tests/LibC/TestWctype.cpp b/Tests/LibC/TestWctype.cpp index ed1d7d0028..773cf5bc5c 100644 --- a/Tests/LibC/TestWctype.cpp +++ b/Tests/LibC/TestWctype.cpp @@ -66,3 +66,20 @@ TEST_CASE(iswctype) EXPECT(iswctype(test_chars[i], -1) == 0); } } + +TEST_CASE(towctrans) +{ + 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 mappings are wired to the correct implementation. + for (unsigned int i = 0; i < sizeof(test_chars) / sizeof(test_chars[0]); i++) { + EXPECT(towctrans(test_chars[i], wctrans("tolower")) == towlower(test_chars[i])); + EXPECT(towctrans(test_chars[i], wctrans("toupper")) == towupper(test_chars[i])); + } + + // Test that invalid mappings always return the character unchanged. + for (unsigned int i = 0; i < sizeof(test_chars) / sizeof(test_chars[0]); i++) { + EXPECT(towctrans(test_chars[i], 0) == test_chars[i]); + EXPECT(towctrans(test_chars[i], -1) == test_chars[i]); + } +} |