forked from BigfootDev/flatbuffers
[C++] support native_inline attribute for vector of tables (#7479)
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "monster_test.h"
|
||||
#include "monster_test_generated.h"
|
||||
#include "optional_scalars_test.h"
|
||||
#include "native_inline_table_test_generated.h"
|
||||
#include "parser_test.h"
|
||||
#include "proto_test.h"
|
||||
#include "reflection_test.h"
|
||||
@@ -1362,6 +1363,30 @@ void VectorSpanTest() {
|
||||
}
|
||||
}
|
||||
|
||||
void NativeInlineTableVectorTest() {
|
||||
TestNativeInlineTableT test;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
NativeInlineTableT t;
|
||||
t.a = i;
|
||||
test.t.push_back(t);
|
||||
}
|
||||
|
||||
flatbuffers::FlatBufferBuilder fbb;
|
||||
auto offset = TestNativeInlineTable::Pack(fbb, &test);
|
||||
fbb.Finish(offset);
|
||||
|
||||
auto *root =
|
||||
flatbuffers::GetRoot<TestNativeInlineTable>(fbb.GetBufferPointer());
|
||||
TestNativeInlineTableT unpacked;
|
||||
root->UnPackTo(&unpacked);
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
TEST_ASSERT(unpacked.t[i] == test.t[i]);
|
||||
}
|
||||
|
||||
TEST_ASSERT(unpacked.t == test.t);
|
||||
}
|
||||
|
||||
int FlatBufferTests(const std::string &tests_data_path) {
|
||||
// Run our various test suites:
|
||||
|
||||
@@ -1460,6 +1485,7 @@ int FlatBufferTests(const std::string &tests_data_path) {
|
||||
PrivateAnnotationsLeaks();
|
||||
JsonUnsortedArrayTest();
|
||||
VectorSpanTest();
|
||||
NativeInlineTableVectorTest();
|
||||
return 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user