1
0

test: add test for carton binstore

- rename serialize namespace to serdes.
- fix some compile issue.
- add test for carton binstore
This commit is contained in:
2025-12-16 14:32:02 +08:00
parent 8a7387c7ff
commit fcd0b3364f
8 changed files with 445 additions and 16 deletions

View File

@@ -6,7 +6,7 @@
#define TYPES ::yycc::carton::binstore::types
#define CFG ::yycc::carton::binstore::configuration
#define SERDES ::yycc::carton::binstore::serializer
#define SERDES ::yycc::carton::binstore::serdes
#define SAFECAST ::yycc::num::safe_cast
namespace yycc::carton::binstore::storage {
@@ -129,7 +129,7 @@ namespace yycc::carton::binstore::storage {
TYPES::BinstoreResult<void> Storage::load(std::istream& s, LoadStrategy strategy) {
// Before loading, we need clear all stored raw data first.
this->raws.clear();
this->clear();
// Read identifier
TYPES::VersionIdentifier version;
@@ -171,7 +171,7 @@ namespace yycc::carton::binstore::storage {
auto token = token_finder.value();
// If there is duplicated entry, report error
if (this->raws.contains(token)) std::unexpected(TYPES::BinstoreError::DuplicatedAssign);
if (this->raws.contains(token)) return std::unexpected(TYPES::BinstoreError::DuplicatedAssign);
// Otherwise insert it
this->raws.emplace(token, std::move(ba));
}
@@ -212,6 +212,10 @@ namespace yycc::carton::binstore::storage {
return {};
}
void Storage::clear() {
this->raws.clear();
}
bool Storage::has_setting(TYPES::Token token) const {
return this->cfg.get_settings().has_setting(token);
}