Changes for how Literal changes to normal StringView.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-06-27 14:16:15 +02:00
parent 773e765c83
commit 083c00f85e
3 changed files with 25 additions and 1 deletions

View File

@@ -41,4 +41,26 @@ TEST_CASE("Literal conststring to non literal, then use", "[Utilities]") {
REQUIRE(strcmp(val.c_str(), "foobar") == 0);
}
#ifndef WINDOWS
__attribute__((optnone))
#endif
static ArbUt::StringView
TestCreateConstString() {
char originalVal[7];
originalVal[0] = 'f';
originalVal[1] = 'o';
originalVal[2] = 'o';
originalVal[3] = 'b';
originalVal[4] = 'a';
originalVal[5] = 'r';
originalVal[6] = '\0';
return ArbUt::StringView(originalVal);
}
TEST_CASE("Out of scope char* doesn't lose reference", "[Utilities]") {
ArbUt::StringView val = TestCreateConstString();
INFO(val.c_str());
REQUIRE(strcmp(val.c_str(), "foobar") == 0);
}
#endif