2023-12-18 10:16:31 +00:00
|
|
|
#include "String.h"
|
2022-12-05 17:50:49 +00:00
|
|
|
|
|
|
|
#include "TestFramework.h"
|
2023-12-18 10:16:31 +00:00
|
|
|
//#include "TestUtils.h"
|
|
|
|
#include <iostream>
|
2022-12-05 17:50:49 +00:00
|
|
|
|
2023-12-18 10:16:31 +00:00
|
|
|
TEST_CASE(TestBasicStringOps, "core")
|
|
|
|
{
|
|
|
|
String str;
|
|
|
|
str += 'a';
|
|
|
|
str += 'b';
|
|
|
|
str += 'c';
|
|
|
|
str += 'd';
|
|
|
|
REQUIRE(str == "abcd");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE(TestStringReverse, "core")
|
|
|
|
{
|
|
|
|
String str0;
|
|
|
|
str0.reverse();
|
|
|
|
REQUIRE(str0.empty());
|
|
|
|
|
|
|
|
String str1("a");
|
|
|
|
str1.reverse();
|
|
|
|
REQUIRE(str1 == "a");
|
|
|
|
|
|
|
|
String str2("ab");
|
|
|
|
str2.reverse();
|
|
|
|
REQUIRE(str2 == "ba");
|
|
|
|
|
|
|
|
String str3("abc");
|
|
|
|
str3.reverse();
|
|
|
|
REQUIRE(str3 == "cba");
|
|
|
|
|
|
|
|
String str4("abcd");
|
|
|
|
str4.reverse();
|
|
|
|
REQUIRE(str4 == "dcba");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2022-12-06 18:02:43 +00:00
|
|
|
TEST_CASE(TestStringUtils_StripSurroundingWhitepsace, "core")
|
2022-12-05 17:50:49 +00:00
|
|
|
{
|
|
|
|
std::string input = " super() ";
|
2022-12-06 18:02:43 +00:00
|
|
|
std::string stripped = StringUtils::stripSurroundingWhitepsace(input);
|
|
|
|
REQUIRE(stripped == "super()");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE(TestStringUtils_RemoveUpTo, "core")
|
|
|
|
{
|
|
|
|
std::string input = "def{filename}abc/123/456";
|
|
|
|
std::string removed = StringUtils::removeUpTo(input, "{filename}");
|
|
|
|
REQUIRE(removed == "abc/123/456");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE(TestStringUtils_startsWith, "core")
|
|
|
|
{
|
|
|
|
std::string input = " ```some triple ticks ";
|
|
|
|
bool ignore_whitespace{false};
|
|
|
|
auto starts_with = StringUtils::startsWith(input, "```", ignore_whitespace);
|
|
|
|
REQUIRE(!starts_with);
|
2022-12-05 17:50:49 +00:00
|
|
|
|
2022-12-06 18:02:43 +00:00
|
|
|
ignore_whitespace = true;
|
|
|
|
starts_with = StringUtils::startsWith(input, "```", ignore_whitespace);
|
|
|
|
REQUIRE(starts_with);
|
2022-12-05 17:50:49 +00:00
|
|
|
}
|
2023-12-18 10:16:31 +00:00
|
|
|
|
|
|
|
*/
|