implement blocks data saving/loading

This commit is contained in:
MihailRis
2024-09-30 23:42:16 +03:00
parent e84c79839c
commit 28d746f371
11 changed files with 107 additions and 15 deletions
+16
View File
@@ -53,3 +53,19 @@ TEST(SmallHeap, RandomFill) {
}
EXPECT_EQ(map.sizeOf(map.find(n)), 123);
}
TEST(SmallHeap, EncodeDecode) {
SmallHeap<uint16_t, uint8_t> map;
int n = 3'000;
map.allocate(n, 123);
for (int i = 0; i < n; i++) {
int index = rand() % n;
int size = rand() % 254 + 1;
map.allocate(index, size);
}
auto bytes = map.serialize();
SmallHeap<uint16_t, uint8_t> out;
out.deserialize(bytes.data(), bytes.size());
EXPECT_EQ(map, out);
}