add coverage

This commit is contained in:
2026-02-01 17:15:17 +01:00
parent dd312b9ec5
commit 03e0ce53d5
3 changed files with 48 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
#include <catch2/catch_test_macros.hpp>
#include "helpers/string.hpp"
TEST_CASE("StringHelper::split by char", "[string]") {
const auto tokens = StringHelper::split("a,b,,c", ',');
REQUIRE(tokens.size() == 3);
REQUIRE(tokens[0] == "a");
REQUIRE(tokens[1] == "b");
REQUIRE(tokens[2] == "c");
}
TEST_CASE("StringHelper::split by string", "[string]") {
const auto tokens = StringHelper::split("one::two::three", "::");
REQUIRE(tokens.size() == 3);
REQUIRE(tokens[0] == "one");
REQUIRE(tokens[1] == "two");
REQUIRE(tokens[2] == "three");
}
TEST_CASE("StringHelper::trimToSize", "[string]") {
REQUIRE(StringHelper::trimToSize("hello", 10) == "hello");
REQUIRE(StringHelper::trimToSize("hello world", 5) == "hello...");
}