mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
feat(string): add SStrPrintf
This commit is contained in:
parent
d9e7f05c15
commit
3e24b01fe1
3 changed files with 55 additions and 0 deletions
|
|
@ -207,6 +207,24 @@ TEST_CASE("SStrPack", "[string]") {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE("SStrPrintf", "[string]") {
|
||||
SECTION("fills dest with formatted string") {
|
||||
char dest[100] = { 0 };
|
||||
auto format = "%s - %s";
|
||||
auto length = SStrPrintf(dest, 100, format, "foo", "bar");
|
||||
REQUIRE(length == 9);
|
||||
REQUIRE(!SStrCmp(dest, "foo - bar", SStrLen("foo - bar")));
|
||||
}
|
||||
|
||||
SECTION("fills dest with empty string") {
|
||||
char dest[100] = { 0 };
|
||||
auto format = "";
|
||||
auto length = SStrPrintf(dest, 100, format);
|
||||
REQUIRE(length == 0);
|
||||
REQUIRE(!SStrCmp(dest, "", SStrLen("")));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("SStrStr", "[string]") {
|
||||
SECTION("finds substring when it exists at end of string") {
|
||||
auto string = "foobar";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue