fix(string): correctly handle not found case in SStrStr

This commit is contained in:
fallenoak 2020-11-16 17:54:56 -06:00
parent 001edb9a7a
commit 611186db9e
No known key found for this signature in database
GPG key ID: 7628F8E61AEA070D
2 changed files with 19 additions and 1 deletions

View file

@ -91,6 +91,20 @@ TEST_CASE("SStrStr", "[string]") {
REQUIRE(!SStrCmp(search, substring, SStrLen(search)));
}
SECTION("finds substring when search is empty") {
auto string = "foobar";
auto search = "";
auto substring = SStrStr(string, search);
REQUIRE(!SStrCmp(string, substring, SStrLen(string)));
}
SECTION("returns nullptr when search does not exist in string") {
auto string = "foobar";
auto search = "xyzzy";
auto substring = SStrStr(string, search);
REQUIRE(substring == nullptr);
}
SECTION("returns nullptr when given empty string") {
auto string = "";
auto search = "bar";