diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-07-14 07:23:36 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-14 13:10:23 +0200 |
commit | 0d6dc74951c652cb8e39f3be1b328d2394bea7ea (patch) | |
tree | 550c0a5bb2110a0119b3a1b5b18f479abb135fc5 /Tests/AK | |
parent | ae60357951bb74f3b57946ec946fc97e2638cd42 (diff) | |
download | serenity-0d6dc74951c652cb8e39f3be1b328d2394bea7ea.zip |
AK: Use the correct data types in bitap_bitwise()
Otherwise the bit twiddling goes all wrong and breaks some boundary
cases.
Fixes `StringView::contains(31-chars)`.
Diffstat (limited to 'Tests/AK')
-rw-r--r-- | Tests/AK/TestMemory.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Tests/AK/TestMemory.cpp b/Tests/AK/TestMemory.cpp index 15ba7fe4c7..fbdf3726ae 100644 --- a/Tests/AK/TestMemory.cpp +++ b/Tests/AK/TestMemory.cpp @@ -27,6 +27,13 @@ TEST_CASE(bitap) EXPECT_EQ(result_1, &haystack[2]); EXPECT_EQ(result_2, &haystack[4]); EXPECT_EQ(result_3, nullptr); + + auto haystack_string = "Main function must return c_int\n"sv; + auto needle_string = "Main function must return c_int"sv; + + auto result = AK::Detail::bitap_bitwise(haystack_string.characters_without_null_termination(), haystack_string.length(), needle_string.characters_without_null_termination(), needle_string.length()); + + EXPECT_NE(result, nullptr); } TEST_CASE(kmp_one_chunk) |