Add ForceVectorAlignment64 and test (#7977)

This commit is contained in:
Derek Bailey
2023-05-26 11:49:06 -07:00
committed by GitHub
parent b7856f8e27
commit 96294e9f84
9 changed files with 150 additions and 76 deletions

View File

@@ -438,5 +438,21 @@ void Offset64ManyVectors() {
TEST_EQ(root_table->many_vectors()->Get(12)->vector()->Get(19), 18);
}
void Offset64ForceAlign() {
FlatBufferBuilder64 builder;
// Setup some data to serialize that is less than the force_align size of 32
// bytes.
std::vector<uint8_t> data{ 1, 2, 3 };
// Use the CreateDirect which calls the ForceVectorAlign
const auto root_table_offset =
CreateRootTableDirect(builder, nullptr, 0, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, &data);
// Finish the buffer.
FinishRootTableBuffer(builder, root_table_offset);
}
} // namespace tests
} // namespace flatbuffers