diff options
author | Tim Schumacher <timschumi@gmx.de> | 2021-10-22 00:57:44 +0200 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-10-21 23:57:32 -0700 |
commit | 552ae77f0ddc45b65d88af78f4fa080f4301a65b (patch) | |
tree | d70126597dd3d1255bf4197168877392d2a3b7f5 /Tests/LibC | |
parent | e61860243329c57811aec28ed2eb0ff8c8af760f (diff) | |
download | serenity-552ae77f0ddc45b65d88af78f4fa080f4301a65b.zip |
LibC: Implement wcsnrtombs
Diffstat (limited to 'Tests/LibC')
-rw-r--r-- | Tests/LibC/TestWchar.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Tests/LibC/TestWchar.cpp b/Tests/LibC/TestWchar.cpp index 2e42de4057..4ac7282504 100644 --- a/Tests/LibC/TestWchar.cpp +++ b/Tests/LibC/TestWchar.cpp @@ -364,6 +364,32 @@ TEST_CASE(wcsrtombs) EXPECT_EQ(src, nullptr); } +TEST_CASE(wcsnrtombs) +{ + mbstate_t state = {}; + const wchar_t good_chars[] = { L'\U0001F41E', L'\U0001F41E', L'\0' }; + const wchar_t* src; + size_t ret = 0; + + // Convert nothing. + src = good_chars; + ret = wcsnrtombs(nullptr, &src, 0, 0, &state); + EXPECT_EQ(ret, 0ul); + EXPECT_EQ(src, good_chars); + + // Convert one wide char. + src = good_chars; + ret = wcsnrtombs(nullptr, &src, 1, 0, &state); + EXPECT_EQ(ret, 4ul); + EXPECT_EQ(src, good_chars + 1); + + // Encounter a null character. + src = good_chars; + ret = wcsnrtombs(nullptr, &src, 4, 0, &state); + EXPECT_EQ(ret, 8ul); + EXPECT_EQ(src, nullptr); +} + TEST_CASE(mbsrtowcs) { mbstate_t state = {}; |