common/test/String.cpp

43 lines
1.2 KiB
C++
Raw Permalink Normal View History

2022-12-26 16:26:06 -06:00
#include "common/String.hpp"
#include "test/Test.hpp"
#include <storm/String.hpp>
TEST_CASE("RCString::Copy", "[string]") {
SECTION("copies source string") {
auto str = "foo";
RCString rcStr;
rcStr.Copy(str);
REQUIRE(!SStrCmp(str, rcStr.GetString(), STORM_MAX_STR));
}
SECTION("copies source RCString") {
RCString rcStr1;
rcStr1.Copy("foo");
RCString rcStr2;
rcStr2.Copy(rcStr1);
REQUIRE(!SStrCmp(rcStr1.GetString(), rcStr2.GetString(), STORM_MAX_STR));
}
2022-12-26 16:26:06 -06:00
}
TEST_CASE("RCString::GetString", "[string]") {
SECTION("returns identical pointers for identical source strings") {
auto str1 = "foo";
auto str2 = "foo";
RCString rcStr1;
rcStr1.Copy(str1);
RCString rcStr2;
rcStr2.Copy(str2);
REQUIRE(rcStr1.GetString() == rcStr2.GetString());
}
SECTION("returns different pointers for different source strings") {
auto str1 = "foo1";
auto str2 = "foo2";
RCString rcStr1;
rcStr1.Copy(str1);
RCString rcStr2;
rcStr2.Copy(str2);
REQUIRE(rcStr1.GetString() != rcStr2.GetString());
}
}