mirror of
https://github.com/thunderbrewhq/common.git
synced 2025-12-12 03:02:29 +00:00
feat(datastore): add getter and setter for string
This commit is contained in:
parent
a4dfbeff7a
commit
d1e4812aa3
3 changed files with 52 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "common/DataStore.hpp"
|
||||
#include "test/Test.hpp"
|
||||
#include <storm/String.hpp>
|
||||
|
||||
TEST_CASE("CDataStore::CDataStore", "[datastore]") {
|
||||
SECTION("constructs new data store") {
|
||||
|
|
@ -68,4 +69,28 @@ TEST_CASE("CDataStore::Get", "[datastore]") {
|
|||
|
||||
REQUIRE(readVal == writeVal);
|
||||
}
|
||||
|
||||
SECTION("gets string") {
|
||||
const char* writeVal = "foobar";
|
||||
char readVal[7] = "barfoo";
|
||||
|
||||
CDataStore msg;
|
||||
msg.PutString(writeVal);
|
||||
msg.Finalize();
|
||||
msg.GetString(readVal, sizeof(readVal));
|
||||
|
||||
REQUIRE(SStrCmp(readVal, writeVal, STORM_MAX_STR) == 0);
|
||||
}
|
||||
|
||||
SECTION("gets string honoring maxchars") {
|
||||
const char* writeVal = "foobar";
|
||||
char readVal[7] = "bar";
|
||||
|
||||
CDataStore msg;
|
||||
msg.PutString(writeVal);
|
||||
msg.Finalize();
|
||||
msg.GetString(readVal, 3);
|
||||
|
||||
REQUIRE(SStrCmp(readVal, "foo", STORM_MAX_STR) == 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue