mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
make StructLayout serializable
This commit is contained in:
parent
8447cf5ad5
commit
f5d2a1f1b7
5 changed files with 134 additions and 8 deletions
|
|
@ -114,3 +114,20 @@ TEST(StructLayout, ConvertWithLoss) {
|
|||
EXPECT_EQ(dstLayout.getChars(dst, "text"), "tru");
|
||||
EXPECT_EQ(dstLayout.getInteger(dst, "someint"), INT8_MAX);
|
||||
}
|
||||
|
||||
TEST(StructLayout, Serialization) {
|
||||
std::vector<Field> fields {
|
||||
Field {FieldType::CHAR, "text", 5},
|
||||
Field {FieldType::I16, "someint", 1},
|
||||
Field {FieldType::F64, "pi", 1},
|
||||
};
|
||||
auto layout1 = StructLayout::create(fields);
|
||||
auto serialized = layout1.serialize();
|
||||
|
||||
std::cout << *serialized << std::endl;
|
||||
|
||||
StructLayout layout2;
|
||||
layout2.deserialize(serialized.get());
|
||||
|
||||
EXPECT_EQ(layout1, layout2);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue