diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/monster_test.fbs | 3 | ||||
-rwxr-xr-x | tests/monster_test_generated.h | 4 | ||||
-rw-r--r-- | tests/test.cpp | 4 |
3 files changed, 10 insertions, 1 deletions
diff --git a/tests/monster_test.fbs b/tests/monster_test.fbs index caf6946d..bdf4aaea 100755 --- a/tests/monster_test.fbs +++ b/tests/monster_test.fbs @@ -36,3 +36,6 @@ table Monster { } root_type Monster; + +file_identifier "MONS"; +file_extension "mon"; diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h index aed7ea23..42dc4189 100755 --- a/tests/monster_test_generated.h +++ b/tests/monster_test_generated.h @@ -187,6 +187,10 @@ inline const Monster *GetMonster(const void *buf) { return flatbuffers::GetRoot< inline bool VerifyMonsterBuffer(const flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer<Monster>(); } +inline void FinishMonsterBuffer(flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<Monster> root) { fbb.Finish(root, "MONS"); } + +inline bool MonsterBufferHasIdentifier(const void *buf) { return flatbuffers::BufferHasIdentifier(buf, "MONS"); } + } // namespace Example } // namespace MyGame diff --git a/tests/test.cpp b/tests/test.cpp index f8608975..e10367c4 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -93,7 +93,7 @@ std::string CreateFlatBufferTest() { Any_Monster, mloc2.Union(), // Store a union. testv, vecofstrings, vecoftables, 0); - builder.Finish(mloc); + FinishMonsterBuffer(builder, mloc); #ifdef FLATBUFFERS_TEST_VERBOSE // print byte data for debugging: @@ -116,6 +116,8 @@ void AccessFlatBufferTest(const std::string &flatbuf) { flatbuf.length()); TEST_EQ(VerifyMonsterBuffer(verifier), true); + TEST_EQ(MonsterBufferHasIdentifier(flatbuf.c_str()), true); + // Access the buffer from the root. auto monster = GetMonster(flatbuf.c_str()); |