Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions common/string/RCString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ const char* RCString::GetString() const {
return nullptr;
}
}

void RCString::operator=(const char* rval) {
this->Copy(rval);
}
1 change: 1 addition & 0 deletions common/string/RCString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class RCString : public TRefCnt {
void Copy(const RCString& source);
void Get(char* buf, size_t bufSize) const;
const char* GetString() const;
void operator=(const char* rval);
};

#endif
9 changes: 9 additions & 0 deletions test/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@ TEST_CASE("RCString::GetString", "[string]") {
REQUIRE(rcStr1.GetString() != rcStr2.GetString());
}
}

TEST_CASE("RCString::operator=", "string") {
SECTION("assigns the value of const char* rval to the calling RCString object") {
auto str = "foo";
RCString rcStr;
rcStr = str;
REQUIRE(!SStrCmp(str, rcStr.GetString(), STORM_MAX_STR));
}
}