C++: Add option to skip verifying nested flatbuffers (#7489)

* C++: Add option to skip verifying nested flatbuffers

Additionally, add an options struct to the verifier for those
who prefer designated initializers to default arguments. The former
constructor is defined in terms of the latter because in old c++,
having default values for members removes list initialization, making
defining constructors in the other way a lot more challenging to write.

* fixes

* fmt

* formatting, and remove an argument

* fix

Co-authored-by: Casper Neo <cneo@google.com>
Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
Casper
2022-08-29 19:25:57 -04:00
committed by GitHub
parent 6a87427540
commit 41d9add7ef
2 changed files with 49 additions and 13 deletions

View File

@@ -1085,6 +1085,14 @@ void NestedVerifierTest() {
flatbuffers::Verifier verifier(builder.GetBufferPointer(),
builder.GetSize());
TEST_EQ(false, VerifyMonsterBuffer(verifier));
// Verify the root monster succeeds, since we've disabled checking nested
// flatbuffers
flatbuffers::Verifier::Options options;
options.check_nested_flatbuffers = false;
flatbuffers::Verifier no_check_nested(builder.GetBufferPointer(),
builder.GetSize(), options);
TEST_EQ(true, VerifyMonsterBuffer(no_check_nested));
}
{