Resolve issue where ConstString can lose internal string representation due to not owning it.
Some checks failed
continuous-integration/drone/push Build is failing

This sadly meant most constexpr constructors had to be removed, as it needs to copy the string.
This commit is contained in:
2020-04-07 18:54:23 +02:00
parent 460f9308a0
commit 6b4d18f434
3 changed files with 37 additions and 10 deletions

View File

@@ -42,5 +42,23 @@ TEST_CASE("Use case insensitive const string in switch case", "[Utilities]") {
}
}
__attribute__((optnone))
static Arbutils::CaseInsensitiveConstString TestCreateConstString(){
char originalVal [6];
originalVal[0] = 'f';
originalVal[1] = 'o';
originalVal[2] = 'o';
originalVal[3] = 'b';
originalVal[4] = 'a';
originalVal[5] = 'r';
return Arbutils::CaseInsensitiveConstString(originalVal);
}
TEST_CASE("Out of scope char* doesn't lose reference", "[Utilities]") {
Arbutils::CaseInsensitiveConstString val = TestCreateConstString();
INFO(val.c_str());
REQUIRE(strcmp(val.c_str(), "foobar") == 0);
}
#endif