#include "String.h" #include "TestFramework.h" //#include "TestUtils.h" #include TEST_CASE(String_Append, "core") { String str; str += 'a'; str += 'b'; str += 'c'; str += 'd'; REQUIRE(str == "abcd"); String long_string("abc/def/ghi/jkl"); } TEST_CASE(String_Reverse, "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"); } TEST_CASE(String_Extend, "core") { String str("/home/jgrogan/code/compilz/src/src"); auto str_cpy = str; str += "/"; str += "test"; REQUIRE(str == String("/home/jgrogan/code/compilz/src/src/test")); str_cpy += "/"; str_cpy += "test"; REQUIRE(str == str_cpy); } TEST_CASE(String_Slice, "core") { String str("test.dat"); const auto rindex = str.rindex('.'); REQUIRE(rindex.valid()); REQUIRE(rindex.value() == 4); String right; str.slice(rindex.value(), str.size(), right); REQUIRE(right == ".dat"); const auto split = str.rsplit('.'); REQUIRE(split.first() == "test"); REQUIRE(split.second() == "dat"); } /* TEST_CASE(TestStringUtils_StripSurroundingWhitepsace, "core") { std::string input = " super() "; 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); ignore_whitespace = true; starts_with = StringUtils::startsWith(input, "```", ignore_whitespace); REQUIRE(starts_with); } */