diff options
author | Jon Simantov <jsimantov@google.com> | 2022-01-25 17:01:16 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-25 14:01:16 -0800 |
commit | a2d38fbb9881ee64056fe2f6fe8aeb0b9eec9de9 (patch) | |
tree | a4cb1f9852b2137103686f4498566ad57f6382e4 /tests | |
parent | 9ef1524d3fe71351dfd99913e148ec588e45f7d4 (diff) | |
download | flatbuffers-a2d38fbb9881ee64056fe2f6fe8aeb0b9eec9de9.tar.gz flatbuffers-a2d38fbb9881ee64056fe2f6fe8aeb0b9eec9de9.tar.bz2 flatbuffers-a2d38fbb9881ee64056fe2f6fe8aeb0b9eec9de9.zip |
Add --warnings-as-errors to flatc compiler. (#7034)
* Add --warnings-as-errors to flatc compiler.
With this option set, flatc will return an error on parsing if
any warnings occurred.
* Add unit test for opts.warnings_as_errors.
* Change explicit option setting to default.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test.cpp b/tests/test.cpp index 2c490a82..1fa75fe7 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -2943,6 +2943,25 @@ void StructUnionTest() { gadget.Set(fan); } +void WarningsAsErrorsTest() { + { + flatbuffers::IDLOptions opts; + // opts.warnings_as_errors should default to false + flatbuffers::Parser parser(opts); + TEST_EQ(parser.Parse("table T { THIS_NAME_CAUSES_A_WARNING:string;}\n" + "root_type T;"), + true); + } + { + flatbuffers::IDLOptions opts; + opts.warnings_as_errors = true; + flatbuffers::Parser parser(opts); + TEST_EQ(parser.Parse("table T { THIS_NAME_CAUSES_A_WARNING:string;}\n" + "root_type T;"), + false); + } +} + void ConformTest() { flatbuffers::Parser parser; TEST_EQ(parser.Parse("table T { A:int; } enum E:byte { A }"), true); @@ -4209,6 +4228,7 @@ int FlatBufferTests() { FlatbuffersIteratorsTest(); FixedLengthArraySpanTest(); StructUnionTest(); + WarningsAsErrorsTest(); return 0; } |