mirror of
https://github.com/thunderbrewhq/common.git
synced 2025-12-12 03:02:29 +00:00
fix(datastore): correctly handle null terminated strings
This commit is contained in:
parent
d1e4812aa3
commit
156ccfdb7d
2 changed files with 21 additions and 3 deletions
|
|
@ -80,9 +80,10 @@ TEST_CASE("CDataStore::Get", "[datastore]") {
|
|||
msg.GetString(readVal, sizeof(readVal));
|
||||
|
||||
REQUIRE(SStrCmp(readVal, writeVal, STORM_MAX_STR) == 0);
|
||||
REQUIRE(msg.IsRead());
|
||||
}
|
||||
|
||||
SECTION("gets string honoring maxchars") {
|
||||
SECTION("gets string honoring maxchars > 0") {
|
||||
const char* writeVal = "foobar";
|
||||
char readVal[7] = "bar";
|
||||
|
||||
|
|
@ -92,5 +93,18 @@ TEST_CASE("CDataStore::Get", "[datastore]") {
|
|||
msg.GetString(readVal, 3);
|
||||
|
||||
REQUIRE(SStrCmp(readVal, "foo", STORM_MAX_STR) == 0);
|
||||
REQUIRE(msg.m_read == 3);
|
||||
}
|
||||
|
||||
SECTION("gets string honoring maxchars of 0") {
|
||||
const char* writeVal = "foobar";
|
||||
char readVal[7] = "bar";
|
||||
|
||||
CDataStore msg;
|
||||
msg.PutString(writeVal);
|
||||
msg.Finalize();
|
||||
msg.GetString(readVal, 0);
|
||||
|
||||
REQUIRE(msg.m_read == 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue