1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

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)`.
This commit is contained in:
Ali Mohammad Pur 2022-07-14 07:23:36 +04:30 committed by Andreas Kling
parent ae60357951
commit 0d6dc74951
2 changed files with 9 additions and 2 deletions

View file

@ -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)