我有以下测试示例FlatBuffers Schema:
namespace test;
struct Vec3 {
x:float;
y:float;
z:float;
}
table Test {
pos:[Vec3] (id:0);
}
root_type Test;
当我编写一个简单的测试代码时,验证程序返回false
,我不明白。数据似乎正确......?
#include <flatbuffers/flatbuffers.h>
#include "testbuffer_generated.h"
namespace t = test;
unsigned int n = 1; // How many positions we store
flatbuffers::FlatBufferBuilder builder;
std::vector<t::Vec3> vecs(n, t::Vec3(1, 3, 4));
auto vecsOffsets = builder.CreateVectorOfStructs(vecs.data(), vecs.size());
auto testBuilder = t::TestBuilder(builder);
testBuilder.add_pos(vecsOffsets);
auto test = testBuilder.Finish();
builder.Finish(test);
uint8_t* file = builder.GetBufferPointer();
std::size_t size = builder.GetSize();
flatbuffers::Verifier v(file, size);
std::cout << t::VerifyTestBuffer(v); << std::endl;
我正在使用https://github.com/google/flatbuffers
中的主分支有人知道可能出现什么问题吗?