diff options
author | Tim Schumacher <timschumi@gmx.de> | 2021-09-22 08:54:23 +0000 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-10-03 05:28:51 +0000 |
commit | 5ac2e84264a669dc207be63d0fc746887a1d241f (patch) | |
tree | 2e9b4a55182b09b59a791420b6b99772976480c5 /Tests | |
parent | 1b078f87b77e65afac3a998af8223bbebe729df0 (diff) | |
download | serenity-5ac2e84264a669dc207be63d0fc746887a1d241f.zip |
LibC: Implement wcsstr
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/LibC/TestWchar.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Tests/LibC/TestWchar.cpp b/Tests/LibC/TestWchar.cpp index ed248531a3..949d9ad83c 100644 --- a/Tests/LibC/TestWchar.cpp +++ b/Tests/LibC/TestWchar.cpp @@ -35,6 +35,36 @@ TEST_CASE(wcspbrk) EXPECT_EQ(ret, input + 2); } +TEST_CASE(wcsstr) +{ + const wchar_t* input = L"abcde"; + wchar_t* ret; + + // Empty needle should return haystack. + ret = wcsstr(input, L""); + EXPECT_EQ(ret, input); + + // Test exact match. + ret = wcsstr(input, input); + EXPECT_EQ(ret, input); + + // Test match at string start. + ret = wcsstr(input, L"ab"); + EXPECT_EQ(ret, input); + + // Test match at string end. + ret = wcsstr(input, L"de"); + EXPECT_EQ(ret, input + 3); + + // Test no match. + ret = wcsstr(input, L"z"); + EXPECT_EQ(ret, nullptr); + + // Test needle that is longer than the haystack. + ret = wcsstr(input, L"abcdef"); + EXPECT_EQ(ret, nullptr); +} + TEST_CASE(wcscoll) { // Check if wcscoll is sorting correctly. At the moment we are doing raw char comparisons, |