mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
feat(string): add SStrStr
This commit is contained in:
parent
ac1be572c4
commit
001edb9a7a
3 changed files with 46 additions and 0 deletions
|
|
@ -75,3 +75,26 @@ TEST_CASE("SStrLen", "[string]") {
|
|||
REQUIRE(length == 3);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("SStrStr", "[string]") {
|
||||
SECTION("finds substring when it exists at end of string") {
|
||||
auto string = "foobar";
|
||||
auto search = "bar";
|
||||
auto substring = SStrStr(string, search);
|
||||
REQUIRE(!SStrCmp(search, substring, SStrLen(search)));
|
||||
}
|
||||
|
||||
SECTION("finds substring when it exists at start of string") {
|
||||
auto string = "foobar";
|
||||
auto search = "foo";
|
||||
auto substring = SStrStr(string, search);
|
||||
REQUIRE(!SStrCmp(search, substring, SStrLen(search)));
|
||||
}
|
||||
|
||||
SECTION("returns nullptr when given empty string") {
|
||||
auto string = "";
|
||||
auto search = "bar";
|
||||
auto substring = SStrStr(string, search);
|
||||
REQUIRE(substring == nullptr);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue