summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/monster_test_generated.h4
-rw-r--r--tests/namespace_test/namespace_test1_generated.h2
-rw-r--r--tests/namespace_test/namespace_test2_generated.h12
-rw-r--r--tests/test.cpp18
4 files changed, 27 insertions, 9 deletions
diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h
index 40e7c408..9f3d4de0 100644
--- a/tests/monster_test_generated.h
+++ b/tests/monster_test_generated.h
@@ -510,12 +510,12 @@ inline const MyGame::Example::Monster *GetMonster(const void *buf) { return flat
inline Monster *GetMutableMonster(void *buf) { return flatbuffers::GetMutableRoot<Monster>(buf); }
-inline bool VerifyMonsterBuffer(flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer<MyGame::Example::Monster>(); }
-
inline const char *MonsterIdentifier() { return "MONS"; }
inline bool MonsterBufferHasIdentifier(const void *buf) { return flatbuffers::BufferHasIdentifier(buf, MonsterIdentifier()); }
+inline bool VerifyMonsterBuffer(flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer<MyGame::Example::Monster>(MonsterIdentifier()); }
+
inline const char *MonsterExtension() { return "mon"; }
inline void FinishMonsterBuffer(flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<MyGame::Example::Monster> root) { fbb.Finish(root, MonsterIdentifier()); }
diff --git a/tests/namespace_test/namespace_test1_generated.h b/tests/namespace_test/namespace_test1_generated.h
index 9e10eb4c..23a0964f 100644
--- a/tests/namespace_test/namespace_test1_generated.h
+++ b/tests/namespace_test/namespace_test1_generated.h
@@ -69,7 +69,7 @@ struct TableInNestedNSBuilder {
};
inline flatbuffers::Offset<TableInNestedNS> CreateTableInNestedNS(flatbuffers::FlatBufferBuilder &_fbb,
- int32_t foo = 0) {
+ int32_t foo = 0) {
TableInNestedNSBuilder builder_(_fbb);
builder_.add_foo(foo);
return builder_.Finish();
diff --git a/tests/namespace_test/namespace_test2_generated.h b/tests/namespace_test/namespace_test2_generated.h
index 8e6b3ada..885eae29 100644
--- a/tests/namespace_test/namespace_test2_generated.h
+++ b/tests/namespace_test/namespace_test2_generated.h
@@ -60,9 +60,9 @@ struct TableInFirstNSBuilder {
};
inline flatbuffers::Offset<TableInFirstNS> CreateTableInFirstNS(flatbuffers::FlatBufferBuilder &_fbb,
- flatbuffers::Offset<NamespaceA::NamespaceB::TableInNestedNS> foo_table = 0,
- NamespaceA::NamespaceB::EnumInNestedNS foo_enum = NamespaceA::NamespaceB::EnumInNestedNS_A,
- const NamespaceA::NamespaceB::StructInNestedNS *foo_struct = 0) {
+ flatbuffers::Offset<NamespaceA::NamespaceB::TableInNestedNS> foo_table = 0,
+ NamespaceA::NamespaceB::EnumInNestedNS foo_enum = NamespaceA::NamespaceB::EnumInNestedNS_A,
+ const NamespaceA::NamespaceB::StructInNestedNS *foo_struct = 0) {
TableInFirstNSBuilder builder_(_fbb);
builder_.add_foo_struct(foo_struct);
builder_.add_foo_table(foo_table);
@@ -107,8 +107,8 @@ struct TableInCBuilder {
};
inline flatbuffers::Offset<TableInC> CreateTableInC(flatbuffers::FlatBufferBuilder &_fbb,
- flatbuffers::Offset<NamespaceA::TableInFirstNS> refer_to_a1 = 0,
- flatbuffers::Offset<NamespaceA::SecondTableInA> refer_to_a2 = 0) {
+ flatbuffers::Offset<NamespaceA::TableInFirstNS> refer_to_a1 = 0,
+ flatbuffers::Offset<NamespaceA::SecondTableInA> refer_to_a2 = 0) {
TableInCBuilder builder_(_fbb);
builder_.add_refer_to_a2(refer_to_a2);
builder_.add_refer_to_a1(refer_to_a1);
@@ -146,7 +146,7 @@ struct SecondTableInABuilder {
};
inline flatbuffers::Offset<SecondTableInA> CreateSecondTableInA(flatbuffers::FlatBufferBuilder &_fbb,
- flatbuffers::Offset<NamespaceC::TableInC> refer_to_c = 0) {
+ flatbuffers::Offset<NamespaceC::TableInC> refer_to_c = 0) {
SecondTableInABuilder builder_(_fbb);
builder_.add_refer_to_c(refer_to_c);
return builder_.Finish();
diff --git a/tests/test.cpp b/tests/test.cpp
index 209ec699..402843a6 100644
--- a/tests/test.cpp
+++ b/tests/test.cpp
@@ -15,6 +15,7 @@
*/
#define FLATBUFFERS_DEBUG_VERIFICATION_FAILURE 1
+#define FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
@@ -160,6 +161,23 @@ void AccessFlatBufferTest(const uint8_t *flatbuf, size_t length) {
flatbuffers::Verifier verifier(flatbuf, length);
TEST_EQ(VerifyMonsterBuffer(verifier), true);
+ std::vector<uint8_t> test_buff;
+ test_buff.resize(length * 2);
+ std::memcpy(&test_buff[0], flatbuf , length);
+ std::memcpy(&test_buff[length], flatbuf , length);
+
+ flatbuffers::Verifier verifierl(&test_buff[0], length - 1);
+ TEST_EQ(VerifyMonsterBuffer(verifierl), false);
+ TEST_EQ(verifierl.GetComputedSize(), 0);
+
+ flatbuffers::Verifier verifier1(&test_buff[0], length);
+ TEST_EQ(VerifyMonsterBuffer(verifier1), true);
+ TEST_EQ(verifier1.GetComputedSize(), length);
+
+ flatbuffers::Verifier verifier2(&test_buff[length], length);
+ TEST_EQ(VerifyMonsterBuffer(verifier2), true);
+ TEST_EQ(verifier2.GetComputedSize(), length);
+
TEST_EQ(strcmp(MonsterIdentifier(), "MONS"), 0);
TEST_EQ(MonsterBufferHasIdentifier(flatbuf), true);
TEST_EQ(strcmp(MonsterExtension(), "mon"), 0);