Fix strcasestr()

Fixes #1323
This commit is contained in:
Justine Tunney 2024-11-20 14:06:19 -08:00
parent ad0a7c67c4
commit 5c3f854acb
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2 changed files with 61 additions and 60 deletions

View file

@ -49,6 +49,11 @@ char *strcasestr_naive(const char *haystack, const char *needle) {
return 0;
}
TEST(strcasestr, tester) {
const char *haystack = "Windows";
ASSERT_STREQ(haystack, strcasestr(haystack, "win"));
}
TEST(strcasestr, test_emptyString_isFoundAtBeginning) {
MAKESTRING(haystack, "abc123def");
ASSERT_STREQ(&haystack[0], strcasestr(haystack, gc(strdup(""))));