add StructMapping::setUnicode

This commit is contained in:
MihailRis
2024-08-29 15:10:51 +03:00
parent 4343e81e00
commit 77229b8d9a
3 changed files with 108 additions and 11 deletions
+15
View File
@@ -24,3 +24,18 @@ TEST(StructMapper, ReadWrite) {
mapping.setChars(buffer, "hello", "s");
EXPECT_EQ(mapping.getChars(buffer, "s"), "hell");
}
TEST(StructMapper, Unicode) {
ubyte buffer[8] {};
std::vector<Field> fields {
Field {FieldType::CHAR, "text", 5},
};
auto mapping = StructMapping::create(fields);
EXPECT_EQ(mapping.size(), 5);
mapping.setUnicode(buffer, u8"テキストデモ", "text");
EXPECT_EQ(mapping.getChars(buffer, "text"), std::string(u8""));
mapping.setUnicode(buffer, u8"пример", "text");
EXPECT_EQ(mapping.getChars(buffer, "text"), std::string(u8"пр"));
}