Squashed 'third_party/flatbuffers/' changes from acc9990ab..d6a8dbd26
d6a8dbd26 Experimental fix for failing oss-fuzz coverage build (#6259)
ed391e177 BREAKING: Rust flexbuffers serde human readable set to false (#6257)
a49531414 Update to flags in fuzzing-cmake file (#6256)
de1f0342c Remove _POSIX_C_SOURCE and _XOPEN_SOURCE definitions when compiling o… (#6205)
d0d51e2a5 flatc should support --binary --schema with optional scalar fields. (#6252)
33ab26017 Bump version of rules_go to 0.24.5 (#6234)
febb9d87c Union As Accessors for C# (#6251)
8778dc7c2 Resets buffer without deallocating current pointer (#6247)
aae376e9a Add GetBufferSpan() function to bufferbuilder (#6235)
0ff047148 Modernize android build and sample (#6229)
46a8c7e95 Added required-nested-flatbuffer to monster_test and fixed rust (#6236)
bc56c553e Notify based on Labelling issues and PR (#6241)
07d7cd78a Converted globs to use single quotes (#6240)
cdef70e24 More adjustments to the auto labeler (#6239)
9dd44df35 Updated Lua labeller glob (#6238)
c9b29d088 Support size-prefixed buffers and add tests for size-prefixed messages (#6232)
fba93e0ab Removes duplicate swift in labeler (#6228)
d1a545b1f Added more labels for auto labeler (#6227)
ea92a668d [C#] Optional Scalars (#6217)
6034de286 [Label Bot] Add Java and Kotlin support for the label bot (#6226)
b08b0a440 Implement `Debug` trait for Rust flatbuffers. (#6207)
17ae48dec [Label Bot] Adds some languages to labeler bot (#6222)
fc8097925 Auto Labeler Setup, Just C# for now (#6221)
55658f523 Auto Labeler Setup, Just C# for now (#6218)
14ecfe423 Updated comments and fixed a fundamental type error. (#6214)
a0182cdb1 optional scalars for ts/js (#6215)
0dfcc0a37 Adds NetTest.bat to run .NET Core tests on Windows (#6216)
f9a18ea63 [Java] Implement optional scalars (#6212)
c7586e85a Empties the sharedString map on reset on go and csharp (#6187)
914c64601 Removed C# references from java generator. Move annotations closer to definitions (#6204)
42d7c7997 Adds readable size to asserts in read functions (#6210)
e68e8d7de Refactor idl_gen_rust (#6206)
84809be7e Fix typo in flatbuffers::span declaration. (#6202)
1606fb637 Kotlin test optional enum (#6201)
fe8e3c7e5 Mass Refactoring to use `IsString` and other BASE_TYPE helpers (#6193)
8f6fa4b71 Updated SupportsAdvancedUnionFeatures to look out for string (#6190)
b46db38f5 [JS/TS] Rewrite flexbuffers JS to TS (#6148)
9fa1d2705 Rework enums in rust. (#6098)
a402b3aba idl_gen_json_schema Fix generation of arrays of enums (#6184)
0e1415b99 fix(go_test): remove deprecated grpc call (#6183)
5cd713710 Add generation of JSON Schema to library (#6165)
5be777e1d Bump junit from 4.12 to 4.13.1 in /grpc/tests (#6173)
a49d440ec Bump junit from 4.12 to 4.13.1 in /grpc (#6172)
4ec5e8db9 [C++] Add option to not generate direct copy methods. (#6166)
04bec23a3 Add Array initialization from struct constructor (#5865) (#6147)
77d57fd07 Cast to right type for reserved_ subtraction (#6167)
543c1bbeb Fixed rust nested flatbuffers for tables other than self (#6062)
cb971eece [C++] Fix -Wnarrowing and -Woverflow due to signed bitfields on G++ ARM (#6163)
7b9e61fcc [TS] GRPC Implementation (#6141)
3359e3042 Moved C++ to optional_scalars2 and added some tests. (#6162)
187a4787f [Rust] Upgrade flatbuffers library to 2018 edition (#6159)
08943aa26 Flatbuffer C++ UnpackTo optimization for vectors of non-bool bytes. (#6154)
5975658eb Enables optional enums in swift (#6160)
5d3cf440e Updated Lobster test for optional bools/enums
8ec8322f0 Ruopt enum (#6156)
bbcc85fd4 Fix generation of C++ code with Optional<Enum> (#6155)
0bdf2fa15 [C#] Fix and improve project files (#6142)
2eedc769d possibility to create a vector from an iterator (#6135)
ab01ae162 flatc should output a warning, when an attribute is attached more than once (#6146)
689bfafa7 [Python/JS/TS] Codegen SizeOf method for structs (#6136)
641309a5b unix2dos on tests/FlatBuffers.Test/FlatBuffers.Core.Test.csproj (#6133)
52e362879 SpanT is available in .Net Standard 2.0. (#6137)
dca12522a Add static cast to avoid implicit double promotion. (#6132)
e0bbaa6f9 [C#]Change to ENABLE_SPAN_T that doesn't require UNSAFE_BYTEBUFFER. (#6073)
ab139d6be Revert "[C#] Fix and improve project files (#6116)" (#6130)
34d67b425 Minireflect fixed array (#6129)
96d5e3597 [JS/TS] fix flatbuffers default export (#6123)
eb686a86f Add missed file generated by optional_scalar.fbs (#6125)
750281630 [C#] Fix and improve project files (#6116)
fb4e1c34f Add CharToLower and CharToUpper into util.s (#6126)
8c67b5b12 Add support of Optional<T> scalars to C++ code generator (#6092)
6228b66d3 [Kotlin] Support for optional scalars. (#6115)
e1be8aaad Bump version for latest swift version (#6121)
94873e595 [JS/TS] Modernize TypeScript / JavaScript flatbuffers support (#6095)
b8e87fafe [JS] Add getFullyQualifiedName() (#6119)
f96d1ef74 [Java] allowing larger buffer sizes when growing a byte buffer (#6118)
89435303b [Swift] Migrates struct write APIS to write directly to the buffer (#6093)
c75ae2429 Optional-ness in reflection (#6097)
338944d3d Rename Nullable scalars to Optional scalars (#6112)
f5ab24bc4 Avoid memcpy call for empty vectors (#6111)
92a8c1a0f [JS] FlexBuffers Fix for wrong type of offset and length values (#6107)
6cea45dcd fix c# json serializer commandline argument docs (#6104)
fec58aa12 Fix for issue 6100: incorrect shrinking logic in ResizeContext() (#6102)
71aca81ff [JS] FlexBuffers Support (#5973)
04d87ffec [C++] Small refactoring of the C++ code generator (#6091)
bb25956f0 Wrap verify file id condition in Check call (#6085)
49f4948f0 + Add `removable-media` plug to the snapcraft config (#6083)
eeacc53d2 Adds proper access types for swift object api & flatbuffers & grpc (#6081)
f3003e08d [Lobster] missed a test
d713a0084 [CMake] enabled multi-core builds in VS projects
77f966f89 [Lobster] optional scalars support
e86d5b8e9 [Kotlin] Attach JvmStatic annotation to each method in companion object (#6052)
db2aa9b4e [C#] Cleaned up .NET testing script for Mono (#6016)
63cc0eec4 Adds a serialize helper function to native table (#6059)
c30a87de6 [TS] Fix four bugs with imported types in TypeScript. (#6054)
a0fb30575 [Swift] Append namespace for Swift Grpc implementation (#6049)
77c18c1d6 export a __version__ variable for python module (#5309)
f1f23d08e adding fb import when no other imports are present (#6030)
f1025b284 [Feature] Checks for Nullable strings (#6050)
5d052f4e5 [Swift] RFC: Switch Swift namespace from public enum to ordinary concat with _ (#6045)
18b015d25 Rust codegen improvements and lint fixes (#6046)
d76e93f27 adds code gen for optional scalars in swift (#6038)
82fac326c [C++] Fix compiler error from deleted assignment operator (#6036) (#6047)
043b52bd4 Optional Scalars support for Rust (#6034)
c8fa0afdf Allow to run cpp tests under grpc/tests/ using bazel. (#6040)
6d0aae73c Fix git command executed in wrong folder when doing cmake superbuild (#6039)
ff1b73128 [Swift] Optional Scalars Preparation (#6028)
2e48c8dd3 tests: Check for both quiet and signaling NaN on mipsel/hppa (#6029)
6942704f2 support deprecated flag in json schema (#6022)
9ecd2e16c Flatc parser support for nullable scalars (#6026)
33e2d8079 [Dart] Generate constant values map for enums (#6025)
969d0f7a6 Using proper symbol name for reexport (#6021)
515a4052a Silence false positive "-Wstringop-overflow" on GCC 10.0 to 11.0 (#6020)
36fbe6f13 Updated FB import (#6019)
b69fc8cc9 [Java] Add support for shared strings on FlatBufferBuilder. (#6012)
ab6af18d9 Not using non-existent create method for obj api (#6015)
37a5dee10 Code cleanup + updates test and readme (#6004)
8a721f69a Serde with bytes maps to Blob (#6009)
e810635ea [Swift] FlatBuffers createMonster method doesn't treat struct properly (#5992)
4995e1527 Manage grpc dependency in Bazel's WORKSPACE file. (#5995)
60b6066fe Add warning to schema parser if field name is not snake_case. (#6005)
35d45cac7 [Rust] Flexbuffers dependency cleanup and fixes (#5998)
165a6e3d1 Re-added Evolution Schema Code Generation Command (#5999)
13d3fb2ea Fix RPM install conflict (#6003)
d64078eb2 [Swift] Initialize memory when clear ByteBuffer (#5982)
ca1190a3d [TS] Use proper TypedArray in create*Vector (#5991)
7571b2ac5 [C++] Updates real_path to be truly portable (#5787)
e5a8f76a4 [C++] Generate default member initializers for >= C++11 (#5989)
413bb9b55 [Kotlin] Fix Access to union of vector element (#5994)
f35184aef [Swift] Add parsing from unowned UnsafeMutableRawPointer for ByteBuffer (#5981)
b124b7625 Removed requirement that enums be declared in ascending order. (#5887)
0ec7600c6 Do not remove the last digit from float values (#5974)
14baf45c9 Mark GetBufferMinAlignment() const (#5985)
9abb2ec2c TypeScript/JavaScript docs improvements (#5984)
2e57d80b1 [Swift] Internal library improvements (#5965)
cfc7753a4 [Doc] Added missing letters to compiler options (#5976)
12ddc8a92 Rust Flexbuffers Documentation update (#5979)
24ad35709 [docs] typo: updates monsterdata.json to be valid json (#5978)
cc44a4442 [idl_parser] Mark typefield as deprecated (#5958)
9ab4a5c0e Deleted old stale bot
6682cfe87 Increased Operations per run in stale.yml
64922904b Adding Stale Action to clean up PR and Issues
8e505cb67 [C++] Fixed/Enabled --cpp-ptr-type std::shared_ptr [#5813] (#5959)
a28357d7a Propagate boolean default values from proto to fbs (#5964)
7cb4762a6 [Swift] Improving reallocation time by using memcpy and moving reallocation code to storage (#5960)
4e45f7c9e Fix error in SimpleQSort (#5955)
7ac026405 fix error on GRPC Python - ignore namespace tree if not specified (#5862) (#5922)
108e981db Required is now implemented in swift (#5952)
94a78e385 Fixed: Access violation and ASAN/UNSAN failures with sorted tables
53fb453e0 [rust] Add FlatBufferBuilder::force_defaults API (#5946)
17c1f35fa [FlexBuffer][Java] ReadWriteBuf and ReadBuf interface public (#5948)
2eaf57778 [Java] Grow ArrayReadWriteBuf enough to match requested capacity. (#5921)
666800da3 Adds bool support in structs + updates grpc support + CI upgrades (#5943)
38ed69eb3 fixed mutating inline values (#5942)
d026e6f07 Add static asserts to ensure that reflection API arrays are kept in sync (#5934)
988164f6e [C++] Got rid of memset's in constructors (#5938)
7179a5a8b General Codebase clean up (#5939)
a0da0c08c Add GetStringView like GetString, GetCstring (#5937)
ac203b209 [C#] Add file identifier to ObjectAPI Serialization Utility. (#5920)
8dd1bf25b not creating creation methods when using structs (#5919)
5aa443d98 [Dart] Adding FlexBuffers support (#5853)
0fa087657 [Dart] Getting tests/DartTest.sh to work on master. (#5915)
424a473e1 Schema parser: prohibit declaration of an array of pointers inside structs (#5907)
c3faa8346 Fix Cargo.toml dependencies (#5911)
91399ad05 fix union type names (#5902)
32782e4ad Update Rust Flexbuffers metadata before publishing (#5905)
e7f3b1690 [TS] Make Obj-API work with --short-names (#5898)
12ed1fe4a fixed invalid imports with --gen-all (#5895)
85ee4df7a [C#] Thread safe reads of Double and Float values from a ByteBuffer (#5900)
de89bd193 Implement flexbuffers in python (#5880)
8be05f6bd Rust Flexbuffers (#5669)
870ecbc09 [swift] Moves code to use VTablesStorage (#5888)
c2da8d5d8 [Java][FlexBuffers] Make FlexBuffersBuilder reusable by adding clear() (#5889) (#5890)
e84cbff67 Align package name to FindFlatBuffers.cmake (#5899)
f94e6c84e Small tutorial improvements - documentation only (#5894)
f12cca8bc Attempt at adding Github Actions CI
7e4124d6e Handle git program or .git folder absence (#5878)
a875d247a only add native_include_files if object based api is enabled (#5886)
6e9f5d981 Respect shared attribute in Parser (#5885)
ff1c78233 include/flatbuffers: typo fixes in comments (#5884)
2e9a19673 Updates swift docs for package management (#5883)
e3cb07d32 [Rust] idl_gen_rust.cpp: (Option/required-aware codegen for unions) (#5850)
712866d57 Propagate use_string_pooling in CopyTable (#5879)
44c919a9e Not using reexports with --gen-all (#5873)
99aa1ef21 Added INCLUDE_PREFIX option for flatbuffers_generate_headers (#5866)
40ba170c9 Fixed text in internals doc that implied structs can be root
cb4d0f72e [Swift] Object API support (#5826)
003e16405 [TS] Add Obj API (#5788)
21cf300f4 fix cpp usage markdown error (#5845)
9655e12d6 Upgraded swift implementation for grpc (#5843)
fb96fadc2 [C#] Fix nested structs and arrays in Object API (#5765)
408f11fbd [ts] Fix empty source/dest namespaces when reexporting. (#5841)
a83caf591 Improves performance for the swift library by using structs + a storage class (#5835)
925fab6b1 [Java][FlexBuffers] Optimize Map access (#5735)
d9fecc332 [CMake] : Add precompiled header support with FLATBUFFERS_ENABLE_PCH (#5827)
e9d453240 Added flatbuffers_generate_headers and flatbuffers_generate_binary_files cmake functions. (#5830)
c37c989ed Correct calculation of vector element size (#5831)
6b271b7ec Fix Clang-trunk warnings about special members deprecated in C++20. (#5829)
90f3b8e8c Fix `float_constant` definition in './doc/Grammar.md` (#5828)
3af735934 [csharp] flatc should generate a 'Create…' method for tables with struct field… (#5818)
c4231c3cb Updated doxyfile - added missing files (#5824)
9657df184 Update Grammar.md (#5820)
97ffc590e Include CPack only when explictly packaging (#5817)
8b52af65b [C++] Add max_depth and max_tables parameters to reflection::Verify (#5815)
9b034eee1 Fix interpretation of 'nan(number)' by the idl_parser (#5810)
3e9ac3cff [Scripts] Adds swift to generated code (#5806)
697147a2e updated maven build files
6df40a247 pre-tag version bump for 1.12
0dba63909 Removes the inner loop in the endtable check written tables (#5803)
0e3fdd0ee Escape characters in jsonschema descriptions (#5644)
45a2b07cb Remove `noexcept` qualifier copy-ctor of `union` type (#5800) (#5802)
d10c16314 Replace 'assert' by 'FLATBUFFERS_ASSERT' inside idl_parser.cpp (#5799)
35abb7f89 Add non-nullable modifier to return type of functions never returning null (#5797)
9954e09ab [C++] Generate code for vector force_align attribute. (#5796)
95a21327f rust: pub export the VectorIter type (#5736)
89b6183ee Fix Python min alignment
5a98d65e8 [Rust] Add gen-name-strings for Rust (#5757)
f73d205bc Removed assert that wasn't backwards compatible.
7c37abe92 [C#] add ObjectAPI Serialization Utility (#5785)
4749e77b0 Fixed docs on how to obtain parser error.
6ff189841 Added --filename-suffix and --filename-ext to flatc (#5778)
c9a30c9ca Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case. (#5777)
8c02d17be Skip writing reflection_generated.h if not changed (#5776)
34305c4ce [Swift] Adds GRPC to Swift (#5758)
cd88e6b2a [Java][FlexBuffers] Abstract buffer access from ByteBuffer (#5743)
3ec7a53c6 Adds cocoapods and a readme of how to get the package (#5771)
6d44cede7 [snap] Fix versioning (#5727)
cc08c0835 [Python] Fixed potential allignment issue (#5768)
54f8b787c Fix memory leak on cpp object api (#5761)
17557f913 [Python] Fixed issue #5499 (#5764)
d54af8cd4 [C++] Use strong enum type for vectors when scoped-enums is on. (#5750)
173e10fdf [C#] support Json Serialization (#5752)
8f56990f6 FlexBuffers: C++: scalar-only typed vectors were not aligned.
6400c9b05 Bump Rust port to 0.6.1 (#5747)
7418d8587 [C#] support Object API (#5710)
c580fa284 Adds min and max, comments, and all of swift's keywords + fix docs (#5737)
f2a127230 Use VS 2017 and 2019 on CI, fix cast issue in dart_idl (#5740)
316d7c208 Creates a flatbuffers validation function + small fix (#5725)
47026ea6b Added the code to embed the binary schema to the source (--bfbs-gen-embed). (#5701)
3f677f241 [Java][FlexBuffers] Deprecate typed vector strings due to design flaw (#5722)
a593a11e5 [Go] Implements a SharedStrings function (#5733)
7cdfc8475 [Swift] Fix padding function overflow when bufSize is 0 (#5721)
bab2b0db4 Add vcpkg installation instructions (#5732)
89418eb84 [Dart] Fix deprecated field support, inf/nan (#5724)
9cadf05d8 [typescript] Size-prefixed root accessors not taking into account size prefix (#5717)
6da1cf79d [rust] Add use declarations to Rust-generated bindings for imported FB definitions (#5645)
bee1df96d [Go] Replace references to hardcoded ”Monster" etc with idiomatic go wherever possible (#5716)
01189d7ed [C++] Fix for printing of enum in case output_enum_identifiers=1. (#5706)
c4b2b0a25 [Swift] Support create long string (#5709)
a4b2884e4 Added create function for swift (#5707)
04d80f255 [Swift] Swift implementation 🎉🎉 (#5603)
55686100a Changed direct calls to strtod to use StringToNumber
718351831 Document JSON compatibility guarantees. (#5704)
d1b34f0f2 Add CMake 'generated_code' target to simplify resolution of build dependencies (#5697)
21b706196 (Optionally) add an additional suffix namespace to generated fbs files. (#5698)
35daaf83d [Java] Replace Table.UTF8_CHARSET with StandardCharsets.UTF_8 (#5696)
3b458f7a1 Rust: Temporarily disable 2 endianness unit tests (#5695)
a5d9d0f7d [C++17] Add Traits class for Tables and Factory function within it. (#5678)
3cd9b6434 Removed code_generators.cpp from library targets
355dfd48d [rust] Make enum names public (#5690)
bcd58a159 Correct inverted logic around include prefixes. (#5689)
a2c12900a Optimize Pack method using numpy (#5662)
901b89e73 [C++] Add Builder and Table typedefs (#5685)
31f879908 Minor doc updates: FlexBuffers C#, Discord, CppUsage.
8023d99e2 Upgrade rules_go (#5684)
b4154405d Fix --incompatible_load_cc_rules_from_bzl (#5683)
04c17c7a7 Add support for absl::string_view when available (#5682)
62ec7d52c [Bazel] Add support for compatible_with and restricted_to (#5681)
7de668053 CI: New Docker tests for Python with numpy (#5677)
3a70e0b30 Fixed struct initialization error on older versions of C#
9b1320135 Fixed warnings in FlexBuffers.java
5e3916050 Fixed out of date licenses on gRPC Python files.
c95755051 Removed test proto output.
44bf71988 Add flatc '--cpp_std' switch (#5656)
3e8f15df9 Fix for FlexBuffers FBT_VECTOR_STRING size bit-width.
602721a73 Added Check to VerifyAlignment (#5675)
13c05f4da Improve import handling for proto conversion (#5673)
ce3a1c43a [Dart] Fix prepare space for writeListInt64 and writeListUint64 (#5654)
aa75e5734 Make Rust constants public (#5659)
2790fee25 Add namespace qualification to union types (#5666)
eddebec1b Bugfix for Rust generation of union fields named with language keywords (#5592)
030fee36a wrap multiple statements in do {} while(!IsConstTrue(true)) (#5655)
f9724d1bd [gRPC] Uncomment MessageBuilder (#5658)
b20801ca4 Supress unsigned-integer-overflow for PaddingBytes (#5647)
a8e800bd7 Add --force-empty-vectors option (#5653)
d7530ae96 Fixed enum min/max values not properly escaped.
99d11e279 Split Bazel targets into multiple packages (#5640)
4fd8eb214 Remove a static_assert (#5643)
65f870357 Flatbuffers Python Object API (#5616)
75823cc27 [Clang 10]: definition of implicit copy constructor for 'TableKeyComparatoris deprecated #5649 (#5650)
58e279244 [docs]: add missing semicolon (#5648)
3c964e10a [GO] Fix support for enums with underscores and Unions with imported members (#5600)
c3c32ec94 Fix ambiguity of a type deduction in TEST_EQ macro if arguments have `enum class` type. (#5630)
075e8d676 Simplify declarations of x-macro FLATBUFFERS_TD (#5638)
bcf1bd5c9 read vtable size through ReadScalar() (#5636)
136d75fa6 Changed null checks in test. Removed verifier pointer usage (#5634)
091fa1fd1 Add testing of C++ with sanitizers (CI-Docker) (#5631)
ff3781dc2 add namespace prefix in FLATBUFFERS_MAX_BUFFER_SIZE (#5629)
6beb9f49c Support for python grpc - continuing the work from the pull request #4270 #4705 (#5613)
80988ea86 Removed idl_gen_general.cpp and move contents to code_generators.cpp (#5625)
0f2ff7eaa Lua cleanup (#5624)
dda095023 [C++] Adds basic schema evolution tests (#5611)
adbcbba5d [C++, C#, Java] Separated C# and Java generators into their own classes (#5618)
cbbd6aca0 add check for root_type specified for json schema generation (#5622)
405c64e07 [Rust] Bump smallvec version to 1.0 (#5621)
42c08cbca Ran src/clang-format-all.sh (#5617)
33d5dd9bd Improved pull request & clang-format instructions.
105dd528e Change monster_extra generation to use flatbuffers::unique_ptr (#5612)
f0f0efe7b [C++] Refactor to conform to Google C++ style guide (#5608)
e837d5a29 Fixed deprecated method in GRPC Java test.
9834ee978 Fixed Apache license not using canonical version.
44b2ab087 include/flatbuffers/base.h: fix no_sanitize issue with old clang (#5610)
46ae3f80a [C++, Java, C#, TypeScript, JavaScript] Skip generation of mutable union types (#5599)
7b38aa71e flatbuffers.h: fix documentation warning (#5607)
661bedd83 Add Lua FlatbufferBuilder Clean() method to enable reuseable builders (#5606)
8526e12d7 [Kotlin] Fix union vector accessor after change in Java API (#5605)
3c7b660d6 [flatc] Remove an always true condition for flexbuffers (#5604)
964365ba6 [Go] Add UnPackTo functions (#5598)
32254b7ac [Go] Object API support (#5339)
521e255ad Rust: Add idiomatic iterator for Vector type (#5579)
1b85292fd Fix typos in comments (#5590)
480815447 C++ verifier for evolved union fields should return true (#5586)
8d5e424c6 Add ByteBuffer copy for vector of bytes in Java (#5587)
b4774d235 Rust: Fix Copy and Clone impls for a few generic types (#5577)
26f238c24 Add `--clean-first` to the cmake-build command (travis) (#5574)
e93c8c46e Fix Follow implementation for bool (#5554)
e21516b9d Fix issue #5557 (#5573)
fbc11e8ae Avoid intentional unsigned integer overflow getting caught by sanitizers (#5572)
e9d29c21a Python: Add forceDefaults opt to python Builder (#5564)
8bfafc76d Java: Don't annotate vector-of-tables item getters with @nullable. (#5562)
df3e8bf4a Fixed warnings generated by recent JSON sorting feature.
5665cfe49 [Java] byte buffer factory returned buffer capcity is used instead of the requested size (#5558)
5797540ed #5544 Fix of Array of table is not sorted if Create<type>Direct() is used (#5546)
7f1af7cb0 Fix build with gcc version 7.4.0 (#5570)
32f47ad24 Fixed JSON parser not sorting vectors of tables/structs with key.
842f672ba [FlexBuffers][Java] Cache size of Sized objects in FlexBuffers (#5551)
d4cae0a62 Fix issue #5542 (#5543)
f1147f65b Fixed Android STLPort related error.
69d3fec48 Fix namespaced struct/field name collision detection (#5540) (#5545)
cfb4ecf6f [flac] Add FlexBuffers option for generating data (#5519)
a92039687 Update Rust versions under test from 1.30.1 to 1.37.0 (#5538)
625338d09 Adds XOPEN_SOURCE for PATH_MAX and POSIX 1993 for stat (#5529)
3f8ce99c5 [FlexBuffers][Java] Add override Key::toString (#5533)
0798b7b69 [FlexBuffers][Java] Fix wrong access to a string using Reference::asString(). (#5532)
cbdf82e2f Fix Mutate() methods of Array<scalar/struct> (override 5508) (#5526)
e365c502f Java: Added access object for vector of struct and vector of tables. (#5233)
97f3aa917 Fixed DetachedBuffer self move assignment (#5521)
2f5bb2eec Fix buildifier warnings found in new bazel (#5517)
917687c7a Fixed Reflection Verifier not handling vectors of unions.
f9277e691 Fixed GenerateText not handling vectors of unions.
2706381ee Add element size parameter to __vector_as_arraysegment [c#] (#5512)
b5560fcd5 [Java][FlexBuffers] Improve documentation for FlexBuffers in Java. (#5506)
782b865c5 Annotate getters with @Pure when --java-checkerframework is specified. (#5510)
3bfc86eaf [Dart]fix: segment fault with empty namespace when generating dart file (#5507)
c0282873f Rust: Fixed cargo clippy on non-generated code (#5485)
4b870aca9 [Javascript] Fix syntax error for signed enum (#5503)
d0e3870c0 [C#] Fix retrieving enumeration vectors as arrays (#5457)
fb25eb87f Doc typo fixes (#5505)
cb35d3a0e Use all of the available space in the buffer returned by ByteBufferFactory to allow the factory to keep a pool of larger than initialsize sized buffers. (#5500)
8e6cabb31 [FlexBuffers][Java] Implementation of FlexBuffers API (#5476)
bd31dd242 Clarified value reuse in FlexBuffers
65b67d213 Fixed test build invocation of arrays_test.fbs
1fbb71132 FlexBuffers: allow any values to be shared.
cd75a3658 Android: remove app_dummy() calls
ec6b0bf29 Fixed STLPort Android compile error
c11b5d744 [bugfix]flexbuffers isvector bugfix (#5488)
4525c91be Fix incorrect padding in arrays of structs (Issue #5484) (#5491)
b97b342f5 Fixed missing generated code.
c1058a903 C++ IDL generation adds superfluous semicolon in GenTablePost, causing (#5483)
303044934 [go]add Name() for ForceCodec interface (#5486)
a2485d4ec reflection: check for valid union enum value during object verification (#5475)
a20e71ac9 has_method support for primitive fields in java runtime. Changed: idl.h, FlatBufferBuilder.java , idl_gen_general.cpp, idl_parser.cpp, flatc.cpp (#5468)
Change-Id: I836f4b43e6818bb16425a87899e6234ac86242aa
git-subtree-dir: third_party/flatbuffers
git-subtree-split: d6a8dbd26ff08a8868e0d0c1b4b67d31b40e4a7f
diff --git a/tests/test.cpp b/tests/test.cpp
index 461840c..6afcb74 100644
--- a/tests/test.cpp
+++ b/tests/test.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include <cmath>
+
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/minireflect.h"
@@ -22,7 +23,6 @@
// clang-format off
#ifdef FLATBUFFERS_CPP98_STL
- #include "flatbuffers/stl_emulation.h"
namespace std {
using flatbuffers::unique_ptr;
}
@@ -34,15 +34,18 @@
#include "namespace_test/namespace_test2_generated.h"
#include "union_vector/union_vector_generated.h"
#include "monster_extra_generated.h"
+#include "optional_scalars_generated.h"
#if !defined(_MSC_VER) || _MSC_VER >= 1700
-#include "arrays_test_generated.h"
+# include "arrays_test_generated.h"
+# include "evolution_test/evolution_v1_generated.h"
+# include "evolution_test/evolution_v2_generated.h"
#endif
#include "native_type_test_generated.h"
#include "test_assert.h"
#include "flatbuffers/flexbuffers.h"
-
+#include "monster_test_bfbs_generated.h" // Generated using --bfbs-comments --bfbs-builtins --cpp --bfbs-gen-embed
// clang-format off
// Check that char* and uint8_t* are interoperable types.
@@ -72,7 +75,8 @@
// http://en.wikipedia.org/wiki/Park%E2%80%93Miller_random_number_generator
uint32_t lcg_seed = 48271;
uint32_t lcg_rand() {
- return lcg_seed = (static_cast<uint64_t>(lcg_seed) * 279470273UL) % 4294967291UL;
+ return lcg_seed =
+ (static_cast<uint64_t>(lcg_seed) * 279470273UL) % 4294967291UL;
}
void lcg_reset() { lcg_seed = 48271; }
@@ -200,14 +204,13 @@
auto vecofcolors = builder.CreateVectorScalarCast<uint8_t, Color>(colors, 2);
// shortcut for creating monster with all fields set:
- auto mloc = CreateMonster(builder, &vec, 150, 80, name, inventory, Color_Blue,
- Any_Monster, mlocs[1].Union(), // Store a union.
- testv, vecofstrings, vecoftables, 0,
- nested_flatbuffer_vector, 0, false, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 3.14159f, 3.0f, 0.0f, vecofstrings2,
- vecofstructs, flex, testv2, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, AnyUniqueAliases_NONE, 0,
- AnyAmbiguousAliases_NONE, 0, vecofcolors);
+ auto mloc = CreateMonster(
+ builder, &vec, 150, 80, name, inventory, Color_Blue, Any_Monster,
+ mlocs[1].Union(), // Store a union.
+ testv, vecofstrings, vecoftables, 0, nested_flatbuffer_vector, 0, false,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.14159f, 3.0f, 0.0f, vecofstrings2,
+ vecofstructs, flex, testv2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ AnyUniqueAliases_NONE, 0, AnyAmbiguousAliases_NONE, 0, vecofcolors);
FinishMonsterBuffer(builder, mloc);
@@ -339,8 +342,9 @@
// Example of accessing a vector of tables:
auto vecoftables = monster->testarrayoftables();
TEST_EQ(vecoftables->size(), 3U);
- for (auto it = vecoftables->begin(); it != vecoftables->end(); ++it)
+ for (auto it = vecoftables->begin(); it != vecoftables->end(); ++it) {
TEST_EQ(strlen(it->name()->c_str()) >= 4, true);
+ }
TEST_EQ_STR(vecoftables->Get(0)->name()->c_str(), "Barney");
TEST_EQ(vecoftables->Get(0)->hp(), 1000);
TEST_EQ_STR(vecoftables->Get(1)->name()->c_str(), "Fred");
@@ -566,8 +570,7 @@
// Create size prefixed buffer.
flatbuffers::FlatBufferBuilder fbb;
FinishSizePrefixedMonsterBuffer(
- fbb,
- CreateMonster(fbb, 0, 200, 300, fbb.CreateString("bob")));
+ fbb, CreateMonster(fbb, 0, 200, 300, fbb.CreateString("bob")));
// Verify it.
flatbuffers::Verifier verifier(fbb.GetBufferPointer(), fbb.GetSize());
@@ -597,7 +600,8 @@
// load FlatBuffer schema (.fbs) from disk
std::string schemafile;
TEST_EQ(flatbuffers::LoadFile((test_data_path + "monster_test.fbs").c_str(),
- false, &schemafile), true);
+ false, &schemafile),
+ true);
// parse schema first, so we can use it to parse the data after
flatbuffers::Parser parser;
auto include_test_path =
@@ -647,6 +651,19 @@
auto result = GenerateText(parser, builder.GetBufferPointer(), &jsongen);
TEST_EQ(result, true);
TEST_EQ(std::string::npos != jsongen.find("color: \"Red Blue\""), true);
+ // Test forward compatibility with 'output_enum_identifiers = true'.
+ // Current Color doesn't have '(1u << 2)' field, let's add it.
+ builder.Clear();
+ std::string future_json;
+ auto future_name = builder.CreateString("future bitflag_enum");
+ MonsterBuilder future_color(builder);
+ future_color.add_name(future_name);
+ future_color.add_color(
+ static_cast<Color>((1u << 2) | Color_Blue | Color_Red));
+ FinishMonsterBuffer(builder, future_color.Finish());
+ result = GenerateText(parser, builder.GetBufferPointer(), &future_json);
+ TEST_EQ(result, true);
+ TEST_EQ(std::string::npos != future_json.find("color: 13"), true);
}
#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
@@ -661,12 +678,23 @@
std::memcpy(&b, &v, sizeof(T));
return ((b & qnan_base) == qnan_base);
}
+#if defined(__mips__) || defined(__hppa__)
+static bool is_quiet_nan(float v) {
+ return is_quiet_nan_impl<float, uint32_t, 0x7FC00000u>(v) ||
+ is_quiet_nan_impl<float, uint32_t, 0x7FBFFFFFu>(v);
+}
+static bool is_quiet_nan(double v) {
+ return is_quiet_nan_impl<double, uint64_t, 0x7FF8000000000000ul>(v) ||
+ is_quiet_nan_impl<double, uint64_t, 0x7FF7FFFFFFFFFFFFu>(v);
+}
+#else
static bool is_quiet_nan(float v) {
return is_quiet_nan_impl<float, uint32_t, 0x7FC00000u>(v);
}
static bool is_quiet_nan(double v) {
return is_quiet_nan_impl<double, uint64_t, 0x7FF8000000000000ul>(v);
}
+#endif
void TestMonsterExtraFloats() {
TEST_EQ(is_quiet_nan(1.0), false);
@@ -770,7 +798,7 @@
true);
auto include_test_path =
- flatbuffers::ConCatPathFileName(test_data_path, "include_test");
+ flatbuffers::ConCatPathFileName(test_data_path, "include_test");
const char *include_directories[] = { test_data_path.c_str(),
include_test_path.c_str(), nullptr };
@@ -781,8 +809,10 @@
reinterpret_cast<const uint8_t *>(schemafile.c_str()),
schemafile.size());
TEST_EQ(reflection::VerifySchemaBuffer(verifier), true);
- //auto schema = reflection::GetSchema(schemafile.c_str());
- TEST_EQ(parser.Deserialize((const uint8_t *)schemafile.c_str(), schemafile.size()), true);
+ // auto schema = reflection::GetSchema(schemafile.c_str());
+ TEST_EQ(parser.Deserialize((const uint8_t *)schemafile.c_str(),
+ schemafile.size()),
+ true);
} else {
TEST_EQ(parser.Parse(schemafile.c_str(), include_directories), true);
}
@@ -870,6 +900,7 @@
TEST_EQ_STR(hp_field.name()->c_str(), "hp");
TEST_EQ(hp_field.id(), 2);
TEST_EQ(hp_field.type()->base_type(), reflection::Short);
+
auto friendly_field_ptr = fields->LookupByKey("friendly");
TEST_NOTNULL(friendly_field_ptr);
TEST_NOTNULL(friendly_field_ptr->attributes());
@@ -883,6 +914,12 @@
TEST_NOTNULL(pos_table_ptr);
TEST_EQ_STR(pos_table_ptr->name()->c_str(), "MyGame.Example.Vec3");
+ // Test nullability of fields: hp is a 0-default scalar, pos is a struct =>
+ // optional, and name is a required string => not optional.
+ TEST_EQ(hp_field.optional(), false);
+ TEST_EQ(pos_field_ptr->optional(), true);
+ TEST_EQ(fields->LookupByKey("name")->optional(), false);
+
// Now use it to dynamically access a buffer.
auto &root = *flatbuffers::GetAnyRoot(flatbuf);
@@ -1028,7 +1065,8 @@
}
void MiniReflectFlatBuffersTest(uint8_t *flatbuf) {
- auto s = flatbuffers::FlatBufferToString(flatbuf, Monster::MiniReflectTypeTable());
+ auto s =
+ flatbuffers::FlatBufferToString(flatbuf, Monster::MiniReflectTypeTable());
TEST_EQ_STR(
s.c_str(),
"{ "
@@ -1059,15 +1097,39 @@
"}");
Test test(16, 32);
- Vec3 vec(1,2,3, 1.5, Color_Red, test);
+ Vec3 vec(1, 2, 3, 1.5, Color_Red, test);
flatbuffers::FlatBufferBuilder vec_builder;
vec_builder.Finish(vec_builder.CreateStruct(vec));
auto vec_buffer = vec_builder.Release();
auto vec_str = flatbuffers::FlatBufferToString(vec_buffer.data(),
Vec3::MiniReflectTypeTable());
+ TEST_EQ_STR(vec_str.c_str(),
+ "{ x: 1.0, y: 2.0, z: 3.0, test1: 1.5, test2: Red, test3: { a: "
+ "16, b: 32 } }");
+}
+
+void MiniReflectFixedLengthArrayTest() {
+ // VS10 does not support typed enums, exclude from tests
+#if !defined(_MSC_VER) || _MSC_VER >= 1700
+ flatbuffers::FlatBufferBuilder fbb;
+ MyGame::Example::ArrayStruct aStruct(2, 12, 1);
+ auto aTable = MyGame::Example::CreateArrayTable(fbb, &aStruct);
+ fbb.Finish(aTable);
+
+ auto flatbuf = fbb.Release();
+ auto s = flatbuffers::FlatBufferToString(
+ flatbuf.data(), MyGame::Example::ArrayTableTypeTable());
TEST_EQ_STR(
- vec_str.c_str(),
- "{ x: 1.0, y: 2.0, z: 3.0, test1: 1.5, test2: Red, test3: { a: 16, b: 32 } }");
+ "{ "
+ "a: { a: 2.0, "
+ "b: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], "
+ "c: 12, "
+ "d: [ { a: [ 0, 0 ], b: A, c: [ A, A ], d: [ 0, 0 ] }, "
+ "{ a: [ 0, 0 ], b: A, c: [ A, A ], d: [ 0, 0 ] } ], "
+ "e: 1, f: [ 0, 0 ] } "
+ "}",
+ s.c_str());
+#endif
}
// Parse a .proto schema, output as .fbs
@@ -1084,11 +1146,10 @@
flatbuffers::LoadFile((test_data_path + "prototest/test.golden").c_str(),
false, &goldenfile),
true);
- TEST_EQ(
- flatbuffers::LoadFile((test_data_path +
- "prototest/test_union.golden").c_str(),
- false, &goldenunionfile),
- true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (test_data_path + "prototest/test_union.golden").c_str(), false,
+ &goldenunionfile),
+ true);
flatbuffers::IDLOptions opts;
opts.include_dependence_headers = false;
@@ -1122,6 +1183,124 @@
TEST_EQ_STR(fbs_union.c_str(), goldenunionfile.c_str());
}
+// Parse a .proto schema, output as .fbs
+void ParseProtoTestWithSuffix() {
+ // load the .proto and the golden file from disk
+ std::string protofile;
+ std::string goldenfile;
+ std::string goldenunionfile;
+ TEST_EQ(
+ flatbuffers::LoadFile((test_data_path + "prototest/test.proto").c_str(),
+ false, &protofile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (test_data_path + "prototest/test_suffix.golden").c_str(), false,
+ &goldenfile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (test_data_path + "prototest/test_union_suffix.golden").c_str(),
+ false, &goldenunionfile),
+ true);
+
+ flatbuffers::IDLOptions opts;
+ opts.include_dependence_headers = false;
+ opts.proto_mode = true;
+ opts.proto_namespace_suffix = "test_namespace_suffix";
+
+ // Parse proto.
+ flatbuffers::Parser parser(opts);
+ auto protopath = test_data_path + "prototest/";
+ const char *include_directories[] = { protopath.c_str(), nullptr };
+ TEST_EQ(parser.Parse(protofile.c_str(), include_directories), true);
+
+ // Generate fbs.
+ auto fbs = flatbuffers::GenerateFBS(parser, "test");
+
+ // Ensure generated file is parsable.
+ flatbuffers::Parser parser2;
+ TEST_EQ(parser2.Parse(fbs.c_str(), nullptr), true);
+ TEST_EQ_STR(fbs.c_str(), goldenfile.c_str());
+
+ // Parse proto with --oneof-union option.
+ opts.proto_oneof_union = true;
+ flatbuffers::Parser parser3(opts);
+ TEST_EQ(parser3.Parse(protofile.c_str(), include_directories), true);
+
+ // Generate fbs.
+ auto fbs_union = flatbuffers::GenerateFBS(parser3, "test");
+
+ // Ensure generated file is parsable.
+ flatbuffers::Parser parser4;
+ TEST_EQ(parser4.Parse(fbs_union.c_str(), nullptr), true);
+ TEST_EQ_STR(fbs_union.c_str(), goldenunionfile.c_str());
+}
+
+// Parse a .proto schema, output as .fbs
+void ParseProtoTestWithIncludes() {
+ // load the .proto and the golden file from disk
+ std::string protofile;
+ std::string goldenfile;
+ std::string goldenunionfile;
+ std::string importprotofile;
+ TEST_EQ(
+ flatbuffers::LoadFile((test_data_path + "prototest/test.proto").c_str(),
+ false, &protofile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (test_data_path + "prototest/imported.proto").c_str(), false,
+ &importprotofile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (test_data_path + "prototest/test_include.golden").c_str(), false,
+ &goldenfile),
+ true);
+ TEST_EQ(flatbuffers::LoadFile(
+ (test_data_path + "prototest/test_union_include.golden").c_str(),
+ false, &goldenunionfile),
+ true);
+
+ flatbuffers::IDLOptions opts;
+ opts.include_dependence_headers = true;
+ opts.proto_mode = true;
+
+ // Parse proto.
+ flatbuffers::Parser parser(opts);
+ auto protopath = test_data_path + "prototest/";
+ const char *include_directories[] = { protopath.c_str(), nullptr };
+ TEST_EQ(parser.Parse(protofile.c_str(), include_directories), true);
+
+ // Generate fbs.
+ auto fbs = flatbuffers::GenerateFBS(parser, "test");
+
+ // Generate fbs from import.proto
+ flatbuffers::Parser import_parser(opts);
+ TEST_EQ(import_parser.Parse(importprotofile.c_str(), include_directories),
+ true);
+ auto import_fbs = flatbuffers::GenerateFBS(import_parser, "test");
+
+ // Ensure generated file is parsable.
+ flatbuffers::Parser parser2;
+ TEST_EQ(
+ parser2.Parse(import_fbs.c_str(), include_directories, "imported.fbs"),
+ true);
+ TEST_EQ(parser2.Parse(fbs.c_str(), nullptr), true);
+ TEST_EQ_STR(fbs.c_str(), goldenfile.c_str());
+
+ // Parse proto with --oneof-union option.
+ opts.proto_oneof_union = true;
+ flatbuffers::Parser parser3(opts);
+ TEST_EQ(parser3.Parse(protofile.c_str(), include_directories), true);
+
+ // Generate fbs.
+ auto fbs_union = flatbuffers::GenerateFBS(parser3, "test");
+
+ // Ensure generated file is parsable.
+ flatbuffers::Parser parser4;
+ TEST_EQ(parser4.Parse(import_fbs.c_str(), nullptr, "imported.fbs"), true);
+ TEST_EQ(parser4.Parse(fbs_union.c_str(), nullptr), true);
+ TEST_EQ_STR(fbs_union.c_str(), goldenunionfile.c_str());
+}
+
template<typename T>
void CompareTableFieldValue(flatbuffers::Table *table,
flatbuffers::voffset_t voffset, T val) {
@@ -1389,7 +1568,7 @@
break;
}
}
- TEST_NOTNULL(NULL);
+ TEST_NOTNULL(nullptr); //-V501 (this comment supresses CWE-570 warning)
}
// clang-format off
@@ -1412,7 +1591,7 @@
("parser.Parse(\"" + std::string(src) + "\")").c_str(), file, line,
func);
} else if (!strstr(parser.error_.c_str(), error_substr)) {
- TestFail(parser.error_.c_str(), error_substr,
+ TestFail(error_substr, parser.error_.c_str(),
("parser.Parse(\"" + std::string(src) + "\")").c_str(), file, line,
func);
}
@@ -1468,7 +1647,7 @@
TestError("enum X:byte { Y } enum X {", "enum already");
TestError("enum X:float {}", "underlying");
TestError("enum X:byte { Y, Y }", "value already");
- TestError("enum X:byte { Y=2, Z=1 }", "ascending");
+ TestError("enum X:byte { Y=2, Z=2 }", "unique");
TestError("table X { Y:int; } table X {", "datatype already");
TestError("struct X (force_align: 7) { Y:int; }", "force_align");
TestError("struct X {}", "size 0");
@@ -1486,6 +1665,11 @@
TestError("table X { Y:int; } root_type X; { Y:1.0 }", "float");
TestError("table X { Y:bool; } root_type X; { Y:1.0 }", "float");
TestError("enum X:bool { Y = true }", "must be integral");
+ // Array of non-scalar
+ TestError("table X { x:int; } struct Y { y:[X:2]; }",
+ "may contain only scalar or struct fields");
+ // Non-snake case field names
+ TestError("table X { Y: int; } root_type Y: {Y:1.0}", "snake_case");
}
template<typename T>
@@ -1497,7 +1681,7 @@
if (check_default) { parser.opts.output_default_scalars_in_json = true; }
// Simple schema.
std::string schema = std::string(decls ? decls : "") + "\n" +
- "table X { Y:" + std::string(type_name) +
+ "table X { y:" + std::string(type_name) +
"; } root_type X;";
auto schema_done = parser.Parse(schema.c_str());
TEST_EQ_STR(parser.error_.c_str(), "");
@@ -1525,47 +1709,46 @@
// Additional parser testing not covered elsewhere.
void ValueTest() {
// Test scientific notation numbers.
- TEST_EQ(FloatCompare(TestValue<float>("{ Y:0.0314159e+2 }", "float"),
- 3.14159f),
- true);
+ TEST_EQ(
+ FloatCompare(TestValue<float>("{ y:0.0314159e+2 }", "float"), 3.14159f),
+ true);
// number in string
- TEST_EQ(FloatCompare(TestValue<float>("{ Y:\"0.0314159e+2\" }", "float"),
+ TEST_EQ(FloatCompare(TestValue<float>("{ y:\"0.0314159e+2\" }", "float"),
3.14159f),
true);
// Test conversion functions.
- TEST_EQ(FloatCompare(TestValue<float>("{ Y:cos(rad(180)) }", "float"), -1),
+ TEST_EQ(FloatCompare(TestValue<float>("{ y:cos(rad(180)) }", "float"), -1),
true);
// int embedded to string
- TEST_EQ(TestValue<int>("{ Y:\"-876\" }", "int=-123"), -876);
- TEST_EQ(TestValue<int>("{ Y:\"876\" }", "int=-123"), 876);
+ TEST_EQ(TestValue<int>("{ y:\"-876\" }", "int=-123"), -876);
+ TEST_EQ(TestValue<int>("{ y:\"876\" }", "int=-123"), 876);
// Test negative hex constant.
- TEST_EQ(TestValue<int>("{ Y:-0x8ea0 }", "int=-0x8ea0"), -36512);
+ TEST_EQ(TestValue<int>("{ y:-0x8ea0 }", "int=-0x8ea0"), -36512);
TEST_EQ(TestValue<int>(nullptr, "int=-0x8ea0"), -36512);
// positive hex constant
- TEST_EQ(TestValue<int>("{ Y:0x1abcdef }", "int=0x1"), 0x1abcdef);
+ TEST_EQ(TestValue<int>("{ y:0x1abcdef }", "int=0x1"), 0x1abcdef);
// with optional '+' sign
- TEST_EQ(TestValue<int>("{ Y:+0x1abcdef }", "int=+0x1"), 0x1abcdef);
+ TEST_EQ(TestValue<int>("{ y:+0x1abcdef }", "int=+0x1"), 0x1abcdef);
// hex in string
- TEST_EQ(TestValue<int>("{ Y:\"0x1abcdef\" }", "int=+0x1"), 0x1abcdef);
+ TEST_EQ(TestValue<int>("{ y:\"0x1abcdef\" }", "int=+0x1"), 0x1abcdef);
// Make sure we do unsigned 64bit correctly.
- TEST_EQ(TestValue<uint64_t>("{ Y:12335089644688340133 }", "ulong"),
+ TEST_EQ(TestValue<uint64_t>("{ y:12335089644688340133 }", "ulong"),
12335089644688340133ULL);
// bool in string
- TEST_EQ(TestValue<bool>("{ Y:\"false\" }", "bool=true"), false);
- TEST_EQ(TestValue<bool>("{ Y:\"true\" }", "bool=\"true\""), true);
- TEST_EQ(TestValue<bool>("{ Y:'false' }", "bool=true"), false);
- TEST_EQ(TestValue<bool>("{ Y:'true' }", "bool=\"true\""), true);
+ TEST_EQ(TestValue<bool>("{ y:\"false\" }", "bool=true"), false);
+ TEST_EQ(TestValue<bool>("{ y:\"true\" }", "bool=\"true\""), true);
+ TEST_EQ(TestValue<bool>("{ y:'false' }", "bool=true"), false);
+ TEST_EQ(TestValue<bool>("{ y:'true' }", "bool=\"true\""), true);
// check comments before and after json object
- TEST_EQ(TestValue<int>("/*before*/ { Y:1 } /*after*/", "int"), 1);
- TEST_EQ(TestValue<int>("//before \n { Y:1 } //after", "int"), 1);
-
+ TEST_EQ(TestValue<int>("/*before*/ { y:1 } /*after*/", "int"), 1);
+ TEST_EQ(TestValue<int>("//before \n { y:1 } //after", "int"), 1);
}
void NestedListTest() {
@@ -1607,8 +1790,8 @@
// For details see C++17 standard or explanation on the SO:
// stackoverflow.com/questions/18195312/what-happens-if-you-static-cast-invalid-value-to-enum-class
TEST_EQ_STR("", EnumNameColor(static_cast<Color>(0)));
- TEST_EQ_STR("", EnumNameColor(static_cast<Color>(Color_ANY-1)));
- TEST_EQ_STR("", EnumNameColor(static_cast<Color>(Color_ANY+1)));
+ TEST_EQ_STR("", EnumNameColor(static_cast<Color>(Color_ANY - 1)));
+ TEST_EQ_STR("", EnumNameColor(static_cast<Color>(Color_ANY + 1)));
}
void EnumOutOfRangeTest() {
@@ -1618,9 +1801,7 @@
TestError("enum X:ubyte { Y = -1 }", "enum value does not fit");
TestError("enum X:ubyte { Y = 256 }", "enum value does not fit");
TestError("enum X:ubyte { Y = 255, Z }", "enum value does not fit");
- // Unions begin with an implicit "NONE = 0".
- TestError("table Y{} union X { Y = -1 }",
- "enum values must be specified in ascending order");
+ TestError("table Y{} union X { Y = -1 }", "enum value does not fit");
TestError("table Y{} union X { Y = 256 }", "enum value does not fit");
TestError("table Y{} union X { Y = 255, Z:Y }", "enum value does not fit");
TestError("enum X:int { Y = -2147483649 }", "enum value does not fit");
@@ -1628,27 +1809,29 @@
TestError("enum X:uint { Y = -1 }", "enum value does not fit");
TestError("enum X:uint { Y = 4294967297 }", "enum value does not fit");
TestError("enum X:long { Y = 9223372036854775808 }", "does not fit");
- TestError("enum X:long { Y = 9223372036854775807, Z }", "enum value does not fit");
+ TestError("enum X:long { Y = 9223372036854775807, Z }",
+ "enum value does not fit");
TestError("enum X:ulong { Y = -1 }", "does not fit");
TestError("enum X:ubyte (bit_flags) { Y=8 }", "bit flag out");
- TestError("enum X:byte (bit_flags) { Y=7 }", "must be unsigned"); // -128
+ TestError("enum X:byte (bit_flags) { Y=7 }", "must be unsigned"); // -128
// bit_flgs out of range
- TestError("enum X:ubyte (bit_flags) { Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8 }", "out of range");
+ TestError("enum X:ubyte (bit_flags) { Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8 }",
+ "out of range");
}
void EnumValueTest() {
- // json: "{ Y:0 }", schema: table X { Y : "E"}
+ // json: "{ Y:0 }", schema: table X { y: "E"}
// 0 in enum (V=0) E then Y=0 is valid.
- TEST_EQ(TestValue<int>("{ Y:0 }", "E", "enum E:int { V }"), 0);
- TEST_EQ(TestValue<int>("{ Y:V }", "E", "enum E:int { V }"), 0);
+ TEST_EQ(TestValue<int>("{ y:0 }", "E", "enum E:int { V }"), 0);
+ TEST_EQ(TestValue<int>("{ y:V }", "E", "enum E:int { V }"), 0);
// A default value of Y is 0.
TEST_EQ(TestValue<int>("{ }", "E", "enum E:int { V }"), 0);
- TEST_EQ(TestValue<int>("{ Y:5 }", "E=V", "enum E:int { V=5 }"), 5);
+ TEST_EQ(TestValue<int>("{ y:5 }", "E=V", "enum E:int { V=5 }"), 5);
// Generate json with defaults and check.
TEST_EQ(TestValue<int>(nullptr, "E=V", "enum E:int { V=5 }"), 5);
// 5 in enum
- TEST_EQ(TestValue<int>("{ Y:5 }", "E", "enum E:int { Z, V=5 }"), 5);
- TEST_EQ(TestValue<int>("{ Y:5 }", "E=V", "enum E:int { Z, V=5 }"), 5);
+ TEST_EQ(TestValue<int>("{ y:5 }", "E", "enum E:int { Z, V=5 }"), 5);
+ TEST_EQ(TestValue<int>("{ y:5 }", "E=V", "enum E:int { Z, V=5 }"), 5);
// Generate json with defaults and check.
TEST_EQ(TestValue<int>(nullptr, "E", "enum E:int { Z, V=5 }"), 0);
TEST_EQ(TestValue<int>(nullptr, "E=V", "enum E:int { Z, V=5 }"), 5);
@@ -1660,7 +1843,9 @@
"enum E:ulong { V = 18446744073709551615 }"),
18446744073709551615ULL);
// Assign non-enum value to enum field. Is it right?
- TEST_EQ(TestValue<int>("{ Y:7 }", "E", "enum E:int { V = 0 }"), 7);
+ TEST_EQ(TestValue<int>("{ y:7 }", "E", "enum E:int { V = 0 }"), 7);
+ // Check that non-ascending values are valid.
+ TEST_EQ(TestValue<int>("{ y:5 }", "E=V", "enum E:int { Z=10, V=5 }"), 5);
}
void IntegerOutOfRangeTest() {
@@ -1733,11 +1918,12 @@
void IntegerBoundaryTest() {
// Check numerical compatibility with non-C++ languages.
- // By the C++ standard, std::numerical_limits<int64_t>::min() == -9223372036854775807 (-2^63+1) or less*
- // The Flatbuffers grammar and most of the languages (C#, Java, Rust) expect
- // that minimum values are: -128, -32768,.., -9223372036854775808.
- // Since C++20, static_cast<int64>(0x8000000000000000ULL) is well-defined two's complement cast.
- // Therefore -9223372036854775808 should be valid negative value.
+ // By the C++ standard, std::numerical_limits<int64_t>::min() ==
+ // -9223372036854775807 (-2^63+1) or less* The Flatbuffers grammar and most of
+ // the languages (C#, Java, Rust) expect that minimum values are: -128,
+ // -32768,.., -9223372036854775808. Since C++20,
+ // static_cast<int64>(0x8000000000000000ULL) is well-defined two's complement
+ // cast. Therefore -9223372036854775808 should be valid negative value.
TEST_EQ(flatbuffers::numeric_limits<int8_t>::min(), -128);
TEST_EQ(flatbuffers::numeric_limits<int8_t>::max(), 127);
TEST_EQ(flatbuffers::numeric_limits<int16_t>::min(), -32768);
@@ -1753,26 +1939,26 @@
TEST_EQ(flatbuffers::numeric_limits<uint64_t>::max(),
18446744073709551615ULL);
- TEST_EQ(TestValue<int8_t>("{ Y:127 }", "byte"), 127);
- TEST_EQ(TestValue<int8_t>("{ Y:-128 }", "byte"), -128);
- TEST_EQ(TestValue<uint8_t>("{ Y:255 }", "ubyte"), 255);
- TEST_EQ(TestValue<uint8_t>("{ Y:0 }", "ubyte"), 0);
- TEST_EQ(TestValue<int16_t>("{ Y:32767 }", "short"), 32767);
- TEST_EQ(TestValue<int16_t>("{ Y:-32768 }", "short"), -32768);
- TEST_EQ(TestValue<uint16_t>("{ Y:65535 }", "ushort"), 65535);
- TEST_EQ(TestValue<uint16_t>("{ Y:0 }", "ushort"), 0);
- TEST_EQ(TestValue<int32_t>("{ Y:2147483647 }", "int"), 2147483647);
- TEST_EQ(TestValue<int32_t>("{ Y:-2147483648 }", "int") + 1, -2147483647);
- TEST_EQ(TestValue<uint32_t>("{ Y:4294967295 }", "uint"), 4294967295);
- TEST_EQ(TestValue<uint32_t>("{ Y:0 }", "uint"), 0);
- TEST_EQ(TestValue<int64_t>("{ Y:9223372036854775807 }", "long"),
+ TEST_EQ(TestValue<int8_t>("{ y:127 }", "byte"), 127);
+ TEST_EQ(TestValue<int8_t>("{ y:-128 }", "byte"), -128);
+ TEST_EQ(TestValue<uint8_t>("{ y:255 }", "ubyte"), 255);
+ TEST_EQ(TestValue<uint8_t>("{ y:0 }", "ubyte"), 0);
+ TEST_EQ(TestValue<int16_t>("{ y:32767 }", "short"), 32767);
+ TEST_EQ(TestValue<int16_t>("{ y:-32768 }", "short"), -32768);
+ TEST_EQ(TestValue<uint16_t>("{ y:65535 }", "ushort"), 65535);
+ TEST_EQ(TestValue<uint16_t>("{ y:0 }", "ushort"), 0);
+ TEST_EQ(TestValue<int32_t>("{ y:2147483647 }", "int"), 2147483647);
+ TEST_EQ(TestValue<int32_t>("{ y:-2147483648 }", "int") + 1, -2147483647);
+ TEST_EQ(TestValue<uint32_t>("{ y:4294967295 }", "uint"), 4294967295);
+ TEST_EQ(TestValue<uint32_t>("{ y:0 }", "uint"), 0);
+ TEST_EQ(TestValue<int64_t>("{ y:9223372036854775807 }", "long"),
9223372036854775807LL);
- TEST_EQ(TestValue<int64_t>("{ Y:-9223372036854775808 }", "long") + 1LL,
+ TEST_EQ(TestValue<int64_t>("{ y:-9223372036854775808 }", "long") + 1LL,
-9223372036854775807LL);
- TEST_EQ(TestValue<uint64_t>("{ Y:18446744073709551615 }", "ulong"),
+ TEST_EQ(TestValue<uint64_t>("{ y:18446744073709551615 }", "ulong"),
18446744073709551615ULL);
- TEST_EQ(TestValue<uint64_t>("{ Y:0 }", "ulong"), 0);
- TEST_EQ(TestValue<uint64_t>("{ Y: 18446744073709551615 }", "uint64"),
+ TEST_EQ(TestValue<uint64_t>("{ y:0 }", "ulong"), 0);
+ TEST_EQ(TestValue<uint64_t>("{ y: 18446744073709551615 }", "uint64"),
18446744073709551615ULL);
// check that the default works
TEST_EQ(TestValue<uint64_t>(nullptr, "uint64 = 18446744073709551615"),
@@ -1781,77 +1967,77 @@
void ValidFloatTest() {
// check rounding to infinity
- TEST_EQ(TestValue<float>("{ Y:+3.4029e+38 }", "float"), +infinityf);
- TEST_EQ(TestValue<float>("{ Y:-3.4029e+38 }", "float"), -infinityf);
- TEST_EQ(TestValue<double>("{ Y:+1.7977e+308 }", "double"), +infinityd);
- TEST_EQ(TestValue<double>("{ Y:-1.7977e+308 }", "double"), -infinityd);
+ TEST_EQ(TestValue<float>("{ y:+3.4029e+38 }", "float"), +infinityf);
+ TEST_EQ(TestValue<float>("{ y:-3.4029e+38 }", "float"), -infinityf);
+ TEST_EQ(TestValue<double>("{ y:+1.7977e+308 }", "double"), +infinityd);
+ TEST_EQ(TestValue<double>("{ y:-1.7977e+308 }", "double"), -infinityd);
TEST_EQ(
- FloatCompare(TestValue<float>("{ Y:0.0314159e+2 }", "float"), 3.14159f),
+ FloatCompare(TestValue<float>("{ y:0.0314159e+2 }", "float"), 3.14159f),
true);
// float in string
- TEST_EQ(FloatCompare(TestValue<float>("{ Y:\" 0.0314159e+2 \" }", "float"),
+ TEST_EQ(FloatCompare(TestValue<float>("{ y:\" 0.0314159e+2 \" }", "float"),
3.14159f),
true);
- TEST_EQ(TestValue<float>("{ Y:1 }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ Y:1.0 }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ Y:1. }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ Y:+1. }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ Y:-1. }", "float"), -1.0f);
- TEST_EQ(TestValue<float>("{ Y:1.e0 }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ Y:1.e+0 }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ Y:1.e-0 }", "float"), 1.0f);
- TEST_EQ(TestValue<float>("{ Y:0.125 }", "float"), 0.125f);
- TEST_EQ(TestValue<float>("{ Y:.125 }", "float"), 0.125f);
- TEST_EQ(TestValue<float>("{ Y:-.125 }", "float"), -0.125f);
- TEST_EQ(TestValue<float>("{ Y:+.125 }", "float"), +0.125f);
- TEST_EQ(TestValue<float>("{ Y:5 }", "float"), 5.0f);
- TEST_EQ(TestValue<float>("{ Y:\"5\" }", "float"), 5.0f);
+ TEST_EQ(TestValue<float>("{ y:1 }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:1.0 }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:1. }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:+1. }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:-1. }", "float"), -1.0f);
+ TEST_EQ(TestValue<float>("{ y:1.e0 }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:1.e+0 }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:1.e-0 }", "float"), 1.0f);
+ TEST_EQ(TestValue<float>("{ y:0.125 }", "float"), 0.125f);
+ TEST_EQ(TestValue<float>("{ y:.125 }", "float"), 0.125f);
+ TEST_EQ(TestValue<float>("{ y:-.125 }", "float"), -0.125f);
+ TEST_EQ(TestValue<float>("{ y:+.125 }", "float"), +0.125f);
+ TEST_EQ(TestValue<float>("{ y:5 }", "float"), 5.0f);
+ TEST_EQ(TestValue<float>("{ y:\"5\" }", "float"), 5.0f);
- #if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
+#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
// Old MSVC versions may have problem with this check.
// https://www.exploringbinary.com/visual-c-plus-plus-strtod-still-broken/
- TEST_EQ(TestValue<double>("{ Y:6.9294956446009195e15 }", "double"),
- 6929495644600920.0);
+ TEST_EQ(TestValue<double>("{ y:6.9294956446009195e15 }", "double"),
+ 6929495644600920.0);
// check nan's
- TEST_EQ(std::isnan(TestValue<double>("{ Y:nan }", "double")), true);
- TEST_EQ(std::isnan(TestValue<float>("{ Y:nan }", "float")), true);
- TEST_EQ(std::isnan(TestValue<float>("{ Y:\"nan\" }", "float")), true);
- TEST_EQ(std::isnan(TestValue<float>("{ Y:+nan }", "float")), true);
- TEST_EQ(std::isnan(TestValue<float>("{ Y:-nan }", "float")), true);
+ TEST_EQ(std::isnan(TestValue<double>("{ y:nan }", "double")), true);
+ TEST_EQ(std::isnan(TestValue<float>("{ y:nan }", "float")), true);
+ TEST_EQ(std::isnan(TestValue<float>("{ y:\"nan\" }", "float")), true);
+ TEST_EQ(std::isnan(TestValue<float>("{ y:+nan }", "float")), true);
+ TEST_EQ(std::isnan(TestValue<float>("{ y:-nan }", "float")), true);
TEST_EQ(std::isnan(TestValue<float>(nullptr, "float=nan")), true);
TEST_EQ(std::isnan(TestValue<float>(nullptr, "float=-nan")), true);
// check inf
- TEST_EQ(TestValue<float>("{ Y:inf }", "float"), infinityf);
- TEST_EQ(TestValue<float>("{ Y:\"inf\" }", "float"), infinityf);
- TEST_EQ(TestValue<float>("{ Y:+inf }", "float"), infinityf);
- TEST_EQ(TestValue<float>("{ Y:-inf }", "float"), -infinityf);
+ TEST_EQ(TestValue<float>("{ y:inf }", "float"), infinityf);
+ TEST_EQ(TestValue<float>("{ y:\"inf\" }", "float"), infinityf);
+ TEST_EQ(TestValue<float>("{ y:+inf }", "float"), infinityf);
+ TEST_EQ(TestValue<float>("{ y:-inf }", "float"), -infinityf);
TEST_EQ(TestValue<float>(nullptr, "float=inf"), infinityf);
TEST_EQ(TestValue<float>(nullptr, "float=-inf"), -infinityf);
TestValue<double>(
- "{ Y : [0.2, .2, 1.0, -1.0, -2., 2., 1e0, -1e0, 1.0e0, -1.0e0, -3.e2, "
+ "{ y: [0.2, .2, 1.0, -1.0, -2., 2., 1e0, -1e0, 1.0e0, -1.0e0, -3.e2, "
"3.0e2] }",
"[double]");
TestValue<float>(
- "{ Y : [0.2, .2, 1.0, -1.0, -2., 2., 1e0, -1e0, 1.0e0, -1.0e0, -3.e2, "
+ "{ y: [0.2, .2, 1.0, -1.0, -2., 2., 1e0, -1e0, 1.0e0, -1.0e0, -3.e2, "
"3.0e2] }",
"[float]");
// Test binary format of float point.
// https://en.cppreference.com/w/cpp/language/floating_literal
// 0x11.12p-1 = (1*16^1 + 2*16^0 + 3*16^-1 + 4*16^-2) * 2^-1 =
- TEST_EQ(TestValue<double>("{ Y:0x12.34p-1 }", "double"), 9.1015625);
+ TEST_EQ(TestValue<double>("{ y:0x12.34p-1 }", "double"), 9.1015625);
// hex fraction 1.2 (decimal 1.125) scaled by 2^3, that is 9.0
- TEST_EQ(TestValue<float>("{ Y:-0x0.2p0 }", "float"), -0.125f);
- TEST_EQ(TestValue<float>("{ Y:-0x.2p1 }", "float"), -0.25f);
- TEST_EQ(TestValue<float>("{ Y:0x1.2p3 }", "float"), 9.0f);
- TEST_EQ(TestValue<float>("{ Y:0x10.1p0 }", "float"), 16.0625f);
- TEST_EQ(TestValue<double>("{ Y:0x1.2p3 }", "double"), 9.0);
- TEST_EQ(TestValue<double>("{ Y:0x10.1p0 }", "double"), 16.0625);
- TEST_EQ(TestValue<double>("{ Y:0xC.68p+2 }", "double"), 49.625);
- TestValue<double>("{ Y : [0x20.4ep1, +0x20.4ep1, -0x20.4ep1] }", "[double]");
- TestValue<float>("{ Y : [0x20.4ep1, +0x20.4ep1, -0x20.4ep1] }", "[float]");
+ TEST_EQ(TestValue<float>("{ y:-0x0.2p0 }", "float"), -0.125f);
+ TEST_EQ(TestValue<float>("{ y:-0x.2p1 }", "float"), -0.25f);
+ TEST_EQ(TestValue<float>("{ y:0x1.2p3 }", "float"), 9.0f);
+ TEST_EQ(TestValue<float>("{ y:0x10.1p0 }", "float"), 16.0625f);
+ TEST_EQ(TestValue<double>("{ y:0x1.2p3 }", "double"), 9.0);
+ TEST_EQ(TestValue<double>("{ y:0x10.1p0 }", "double"), 16.0625);
+ TEST_EQ(TestValue<double>("{ y:0xC.68p+2 }", "double"), 49.625);
+ TestValue<double>("{ y: [0x20.4ep1, +0x20.4ep1, -0x20.4ep1] }", "[double]");
+ TestValue<float>("{ y: [0x20.4ep1, +0x20.4ep1, -0x20.4ep1] }", "[float]");
#else // FLATBUFFERS_HAS_NEW_STRTOD
TEST_OUTPUT_LINE("FLATBUFFERS_HAS_NEW_STRTOD tests skipped");
@@ -1880,6 +2066,9 @@
TestError("table T { F:float; } root_type T; { F:0x0 }", invalid_msg);
TestError("table T { F:float; } root_type T; { F:-0x. }", invalid_msg);
TestError("table T { F:float; } root_type T; { F:0x. }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:0Xe }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:\"0Xe\" }", invalid_msg);
+ TestError("table T { F:float; } root_type T; { F:\"nan(1)\" }", invalid_msg);
// eE not exponent in hex-float!
TestError("table T { F:float; } root_type T; { F:0x0.0e+ }", invalid_msg);
TestError("table T { F:float; } root_type T; { F:0x0.0e- }", invalid_msg);
@@ -1935,8 +2124,8 @@
TEST_EQ(ok, true);
auto include_test_path =
flatbuffers::ConCatPathFileName(test_data_path, "include_test");
- const char *include_directories[] = {test_data_path.c_str(),
- include_test_path.c_str(), nullptr};
+ const char *include_directories[] = { test_data_path.c_str(),
+ include_test_path.c_str(), nullptr };
flatbuffers::IDLOptions opt;
opt.indent_step = -1;
flatbuffers::Parser parser(opt);
@@ -2236,7 +2425,7 @@
// Check independence of identifier from locale.
std::string locale_ident;
locale_ident += "table T { F";
- locale_ident += static_cast<char>(-32); // unsigned 0xE0
+ locale_ident += static_cast<char>(-32); // unsigned 0xE0
locale_ident += " :string; }";
locale_ident += "root_type T;";
locale_ident += "{}";
@@ -2303,15 +2492,121 @@
TEST_EQ(parser1.Parse("{ name: \"Bender\", testnestedflatbuffer: { name: "
"\"Leela\", color: \"nonexistent\"}}"),
false);
- // Check that Parser is destroyed correctly after parsing invalid json
+}
+
+void EvolutionTest() {
+ // VS10 does not support typed enums, exclude from tests
+#if !defined(_MSC_VER) || _MSC_VER >= 1700
+ const int NUM_VERSIONS = 2;
+ std::string schemas[NUM_VERSIONS];
+ std::string jsonfiles[NUM_VERSIONS];
+ std::vector<uint8_t> binaries[NUM_VERSIONS];
+
+ flatbuffers::IDLOptions idl_opts;
+ idl_opts.lang_to_generate |= flatbuffers::IDLOptions::kBinary;
+ flatbuffers::Parser parser(idl_opts);
+
+ // Load all the schema versions and their associated data.
+ for (int i = 0; i < NUM_VERSIONS; ++i) {
+ std::string schema = test_data_path + "evolution_test/evolution_v" +
+ flatbuffers::NumToString(i + 1) + ".fbs";
+ TEST_ASSERT(flatbuffers::LoadFile(schema.c_str(), false, &schemas[i]));
+ std::string json = test_data_path + "evolution_test/evolution_v" +
+ flatbuffers::NumToString(i + 1) + ".json";
+ TEST_ASSERT(flatbuffers::LoadFile(json.c_str(), false, &jsonfiles[i]));
+
+ TEST_ASSERT(parser.Parse(schemas[i].c_str()));
+ TEST_ASSERT(parser.Parse(jsonfiles[i].c_str()));
+
+ auto bufLen = parser.builder_.GetSize();
+ auto buf = parser.builder_.GetBufferPointer();
+ binaries[i].reserve(bufLen);
+ std::copy(buf, buf + bufLen, std::back_inserter(binaries[i]));
+ }
+
+ // Assert that all the verifiers for the different schema versions properly
+ // verify any version data.
+ for (int i = 0; i < NUM_VERSIONS; ++i) {
+ flatbuffers::Verifier verifier(&binaries[i].front(), binaries[i].size());
+ TEST_ASSERT(Evolution::V1::VerifyRootBuffer(verifier));
+ TEST_ASSERT(Evolution::V2::VerifyRootBuffer(verifier));
+ }
+
+ // Test backwards compatibility by reading old data with an evolved schema.
+ auto root_v1_viewed_from_v2 = Evolution::V2::GetRoot(&binaries[0].front());
+ // field 'k' is new in version 2, so it should be null.
+ TEST_ASSERT(nullptr == root_v1_viewed_from_v2->k());
+ // field 'l' is new in version 2 with a default of 56.
+ TEST_EQ(root_v1_viewed_from_v2->l(), 56);
+ // field 'c' of 'TableA' is new in version 2, so it should be null.
+ TEST_ASSERT(nullptr == root_v1_viewed_from_v2->e()->c());
+ // 'TableC' was added to field 'c' union in version 2, so it should be null.
+ TEST_ASSERT(nullptr == root_v1_viewed_from_v2->c_as_TableC());
+ // The field 'c' union should be of type 'TableB' regardless of schema version
+ TEST_ASSERT(root_v1_viewed_from_v2->c_type() == Evolution::V2::Union::TableB);
+ // The field 'f' was renamed to 'ff' in version 2, it should still be
+ // readable.
+ TEST_EQ(root_v1_viewed_from_v2->ff()->a(), 16);
+
+ // Test forwards compatibility by reading new data with an old schema.
+ auto root_v2_viewed_from_v1 = Evolution::V1::GetRoot(&binaries[1].front());
+ // The field 'c' union in version 2 is a new table (index = 3) and should
+ // still be accessible, but not interpretable.
+ TEST_EQ(static_cast<uint8_t>(root_v2_viewed_from_v1->c_type()), 3);
+ TEST_NOTNULL(root_v2_viewed_from_v1->c());
+ // The field 'd' enum in verison 2 has new members and should still be
+ // accessible, but not interpretable.
+ TEST_EQ(static_cast<int8_t>(root_v2_viewed_from_v1->d()), 3);
+ // The field 'a' in version 2 is deprecated and should return the default
+ // value (0) instead of the value stored in the in the buffer (42).
+ TEST_EQ(root_v2_viewed_from_v1->a(), 0);
+ // The field 'ff' was originally named 'f' in version 1, it should still be
+ // readable.
+ TEST_EQ(root_v2_viewed_from_v1->f()->a(), 35);
+#endif
+}
+
+void UnionDeprecationTest() {
+ const int NUM_VERSIONS = 2;
+ std::string schemas[NUM_VERSIONS];
+ std::string jsonfiles[NUM_VERSIONS];
+ std::vector<uint8_t> binaries[NUM_VERSIONS];
+
+ flatbuffers::IDLOptions idl_opts;
+ idl_opts.lang_to_generate |= flatbuffers::IDLOptions::kBinary;
+ flatbuffers::Parser parser(idl_opts);
+
+ // Load all the schema versions and their associated data.
+ for (int i = 0; i < NUM_VERSIONS; ++i) {
+ std::string schema = test_data_path + "evolution_test/evolution_v" +
+ flatbuffers::NumToString(i + 1) + ".fbs";
+ TEST_ASSERT(flatbuffers::LoadFile(schema.c_str(), false, &schemas[i]));
+ std::string json = test_data_path + "evolution_test/evolution_v" +
+ flatbuffers::NumToString(i + 1) + ".json";
+ TEST_ASSERT(flatbuffers::LoadFile(json.c_str(), false, &jsonfiles[i]));
+
+ TEST_ASSERT(parser.Parse(schemas[i].c_str()));
+ TEST_ASSERT(parser.Parse(jsonfiles[i].c_str()));
+
+ auto bufLen = parser.builder_.GetSize();
+ auto buf = parser.builder_.GetBufferPointer();
+ binaries[i].reserve(bufLen);
+ std::copy(buf, buf + bufLen, std::back_inserter(binaries[i]));
+ }
+
+ auto v2 = parser.LookupStruct("Evolution.V2.Root");
+ TEST_NOTNULL(v2);
+ auto j_type_field = v2->fields.Lookup("j_type");
+ TEST_NOTNULL(j_type_field);
+ TEST_ASSERT(j_type_field->deprecated);
}
void UnionVectorTest() {
// load FlatBuffer fbs schema and json.
std::string schemafile, jsonfile;
TEST_EQ(flatbuffers::LoadFile(
- (test_data_path + "union_vector/union_vector.fbs").c_str(),
- false, &schemafile),
+ (test_data_path + "union_vector/union_vector.fbs").c_str(), false,
+ &schemafile),
true);
TEST_EQ(flatbuffers::LoadFile(
(test_data_path + "union_vector/union_vector.json").c_str(),
@@ -2348,12 +2643,11 @@
fbb.CreateStruct(Rapunzel(/*hair_length=*/6)).Union(),
fbb.CreateVector(types), fbb.CreateVector(characters));
FinishMovieBuffer(fbb, movie_offset);
- auto buf = fbb.GetBufferPointer();
- flatbuffers::Verifier verifier(buf, fbb.GetSize());
+ flatbuffers::Verifier verifier(fbb.GetBufferPointer(), fbb.GetSize());
TEST_EQ(VerifyMovieBuffer(verifier), true);
- auto flat_movie = GetMovie(buf);
+ auto flat_movie = GetMovie(fbb.GetBufferPointer());
auto TestMovie = [](const Movie *movie) {
TEST_EQ(movie->main_character_type() == Character_Rapunzel, true);
@@ -2410,6 +2704,7 @@
TestMovie(repacked_movie);
+ // Generate text using mini-reflection.
auto s =
flatbuffers::FlatBufferToString(fbb.GetBufferPointer(), MovieTypeTable());
TEST_EQ_STR(
@@ -2419,43 +2714,81 @@
"characters: [ { books_read: 7 }, { sword_attack_damage: 5 }, "
"{ books_read: 2 }, \"Other\", \"Unused\" ] }");
-
flatbuffers::ToStringVisitor visitor("\n", true, " ");
IterateFlatBuffer(fbb.GetBufferPointer(), MovieTypeTable(), &visitor);
- TEST_EQ_STR(
- visitor.s.c_str(),
- "{\n"
- " \"main_character_type\": \"Rapunzel\",\n"
- " \"main_character\": {\n"
- " \"hair_length\": 6\n"
- " },\n"
- " \"characters_type\": [\n"
- " \"Belle\",\n"
- " \"MuLan\",\n"
- " \"BookFan\",\n"
- " \"Other\",\n"
- " \"Unused\"\n"
- " ],\n"
- " \"characters\": [\n"
- " {\n"
- " \"books_read\": 7\n"
- " },\n"
- " {\n"
- " \"sword_attack_damage\": 5\n"
- " },\n"
- " {\n"
- " \"books_read\": 2\n"
- " },\n"
- " \"Other\",\n"
- " \"Unused\"\n"
- " ]\n"
- "}");
+ TEST_EQ_STR(visitor.s.c_str(),
+ "{\n"
+ " \"main_character_type\": \"Rapunzel\",\n"
+ " \"main_character\": {\n"
+ " \"hair_length\": 6\n"
+ " },\n"
+ " \"characters_type\": [\n"
+ " \"Belle\",\n"
+ " \"MuLan\",\n"
+ " \"BookFan\",\n"
+ " \"Other\",\n"
+ " \"Unused\"\n"
+ " ],\n"
+ " \"characters\": [\n"
+ " {\n"
+ " \"books_read\": 7\n"
+ " },\n"
+ " {\n"
+ " \"sword_attack_damage\": 5\n"
+ " },\n"
+ " {\n"
+ " \"books_read\": 2\n"
+ " },\n"
+ " \"Other\",\n"
+ " \"Unused\"\n"
+ " ]\n"
+ "}");
+
+ // Generate text using parsed schema.
+ std::string jsongen;
+ auto result = GenerateText(parser, fbb.GetBufferPointer(), &jsongen);
+ TEST_EQ(result, true);
+ TEST_EQ_STR(jsongen.c_str(),
+ "{\n"
+ " main_character_type: \"Rapunzel\",\n"
+ " main_character: {\n"
+ " hair_length: 6\n"
+ " },\n"
+ " characters_type: [\n"
+ " \"Belle\",\n"
+ " \"MuLan\",\n"
+ " \"BookFan\",\n"
+ " \"Other\",\n"
+ " \"Unused\"\n"
+ " ],\n"
+ " characters: [\n"
+ " {\n"
+ " books_read: 7\n"
+ " },\n"
+ " {\n"
+ " sword_attack_damage: 5\n"
+ " },\n"
+ " {\n"
+ " books_read: 2\n"
+ " },\n"
+ " \"Other\",\n"
+ " \"Unused\"\n"
+ " ]\n"
+ "}\n");
+
+ // Simple test with reflection.
+ parser.Serialize();
+ auto schema = reflection::GetSchema(parser.builder_.GetBufferPointer());
+ auto ok = flatbuffers::Verify(*schema, *schema->root_table(),
+ fbb.GetBufferPointer(), fbb.GetSize());
+ TEST_EQ(ok, true);
flatbuffers::Parser parser2(idl_opts);
TEST_EQ(parser2.Parse("struct Bool { b:bool; }"
"union Any { Bool }"
"table Root { a:Any; }"
- "root_type Root;"), true);
+ "root_type Root;"),
+ true);
TEST_EQ(parser2.Parse("{a_type:Bool,a:{b:true}}"), true);
}
@@ -2514,9 +2847,11 @@
slb += -100; // Equivalent to slb.Add(-100) or slb.Int(-100);
slb += "Fred";
slb.IndirectFloat(4.0f);
+ auto i_f = slb.LastValue();
uint8_t blob[] = { 77 };
slb.Blob(blob, 1);
slb += false;
+ slb.ReuseValue(i_f);
});
int ints[] = { 1, 2, 3 };
slb.Vector("bar", ints, 3);
@@ -2537,9 +2872,11 @@
slb3 += -100; // Equivalent to slb.Add(-100) or slb.Int(-100);
slb3 += "Fred";
slb3.IndirectFloat(4.0f);
+ auto i_f = slb3.LastValue();
uint8_t blob[] = { 77 };
slb3.Blob(blob, 1);
slb3 += false;
+ slb3.ReuseValue(i_f);
}, slb2);
int ints[] = { 1, 2, 3 };
slb2.Vector("bar", ints, 3);
@@ -2563,7 +2900,7 @@
auto map = flexbuffers::GetRoot(slb.GetBuffer()).AsMap();
TEST_EQ(map.size(), 7);
auto vec = map["vec"].AsVector();
- TEST_EQ(vec.size(), 5);
+ TEST_EQ(vec.size(), 6);
TEST_EQ(vec[0].AsInt64(), -100);
TEST_EQ_STR(vec[1].AsString().c_str(), "Fred");
TEST_EQ(vec[1].AsInt64(), 0); // Number parsing failed.
@@ -2571,13 +2908,11 @@
TEST_EQ(vec[2].AsString().IsTheEmptyString(), true); // Wrong Type.
TEST_EQ_STR(vec[2].AsString().c_str(), ""); // This still works though.
TEST_EQ_STR(vec[2].ToString().c_str(), "4.0"); // Or have it converted.
-
// Few tests for templated version of As.
TEST_EQ(vec[0].As<int64_t>(), -100);
TEST_EQ_STR(vec[1].As<std::string>().c_str(), "Fred");
TEST_EQ(vec[1].As<int64_t>(), 0); // Number parsing failed.
TEST_EQ(vec[2].As<double>(), 4.0);
-
// Test that the blob can be accessed.
TEST_EQ(vec[3].IsBlob(), true);
auto blob = vec[3].AsBlob();
@@ -2585,6 +2920,7 @@
TEST_EQ(blob.data()[0], 77);
TEST_EQ(vec[4].IsBool(), true); // Check if type is a bool
TEST_EQ(vec[4].AsBool(), false); // Check if value is false
+ TEST_EQ(vec[5].AsDouble(), 4.0); // This is shared with vec[2] !
auto tvec = map["bar"].AsTypedVector();
TEST_EQ(tvec.size(), 3);
TEST_EQ(tvec[2].AsInt8(), 3);
@@ -2631,6 +2967,79 @@
// And from FlexBuffer back to JSON:
auto jsonback = jroot.ToString();
TEST_EQ_STR(jsontest, jsonback.c_str());
+
+ slb.Clear();
+ slb.Vector([&]() {
+ for (int i = 0; i < 130; ++i) slb.Add(static_cast<uint8_t>(255));
+ slb.Vector([&]() {
+ for (int i = 0; i < 130; ++i) slb.Add(static_cast<uint8_t>(255));
+ slb.Vector([] {});
+ });
+ });
+ slb.Finish();
+ TEST_EQ(slb.GetSize(), 664);
+}
+
+void FlexBuffersDeprecatedTest() {
+ // FlexBuffers as originally designed had a flaw involving the
+ // FBT_VECTOR_STRING datatype, and this test documents/tests the fix for it.
+ // Discussion: https://github.com/google/flatbuffers/issues/5627
+ flexbuffers::Builder slb;
+ // FBT_VECTOR_* are "typed vectors" where all elements are of the same type.
+ // Problem is, when storing FBT_STRING elements, it relies on that type to
+ // get the bit-width for the size field of the string, which in this case
+ // isn't present, and instead defaults to 8-bit. This means that any strings
+ // stored inside such a vector, when accessed thru the old API that returns
+ // a String reference, will appear to be truncated if the string stored is
+ // actually >=256 bytes.
+ std::string test_data(300, 'A');
+ auto start = slb.StartVector();
+ // This one will have a 16-bit size field.
+ slb.String(test_data);
+ // This one will have an 8-bit size field.
+ slb.String("hello");
+ // We're asking this to be serialized as a typed vector (true), but not
+ // fixed size (false). The type will be FBT_VECTOR_STRING with a bit-width
+ // of whatever the offsets in the vector need, the bit-widths of the strings
+ // are not stored(!) <- the actual design flaw.
+ // Note that even in the fixed code, we continue to serialize the elements of
+ // FBT_VECTOR_STRING as FBT_STRING, since there may be old code out there
+ // reading new data that we want to continue to function.
+ // Thus, FBT_VECTOR_STRING, while deprecated, will always be represented the
+ // same way, the fix lies on the reading side.
+ slb.EndVector(start, true, false);
+ slb.Finish();
+ // So now lets read this data back.
+ // For existing data, since we have no way of knowing what the actual
+ // bit-width of the size field of the string is, we are going to ignore this
+ // field, and instead treat these strings as FBT_KEY (null-terminated), so we
+ // can deal with strings of arbitrary length. This of course truncates strings
+ // with embedded nulls, but we think that that is preferrable over truncating
+ // strings >= 256 bytes.
+ auto vec = flexbuffers::GetRoot(slb.GetBuffer()).AsTypedVector();
+ // Even though this was serialized as FBT_VECTOR_STRING, it is read as
+ // FBT_VECTOR_KEY:
+ TEST_EQ(vec.ElementType(), flexbuffers::FBT_KEY);
+ // Access the long string. Previously, this would return a string of size 1,
+ // since it would read the high-byte of the 16-bit length.
+ // This should now correctly test the full 300 bytes, using AsKey():
+ TEST_EQ_STR(vec[0].AsKey(), test_data.c_str());
+ // Old code that called AsString will continue to work, as the String
+ // accessor objects now use a cached size that can come from a key as well.
+ TEST_EQ_STR(vec[0].AsString().c_str(), test_data.c_str());
+ // Short strings work as before:
+ TEST_EQ_STR(vec[1].AsKey(), "hello");
+ TEST_EQ_STR(vec[1].AsString().c_str(), "hello");
+ // So, while existing code and data mostly "just work" with the fixes applied
+ // to AsTypedVector and AsString, what do you do going forward?
+ // Code accessing existing data doesn't necessarily need to change, though
+ // you could consider using AsKey instead of AsString for a) documenting
+ // that you are accessing keys, or b) a speedup if you don't actually use
+ // the string size.
+ // For new data, or data that doesn't need to be backwards compatible,
+ // instead serialize as FBT_VECTOR (call EndVector with typed = false, then
+ // read elements with AsString), or, for maximum compactness, use
+ // FBT_VECTOR_KEY (call slb.Key above instead, read with AsKey or AsString).
}
void TypeAliasesTest() {
@@ -2659,7 +3068,7 @@
TEST_EQ(ta->u64(), flatbuffers::numeric_limits<uint64_t>::max());
TEST_EQ(ta->f32(), 2.3f);
TEST_EQ(ta->f64(), 2.3);
- using namespace flatbuffers; // is_same
+ using namespace flatbuffers; // is_same
static_assert(is_same<decltype(ta->i8()), int8_t>::value, "invalid type");
static_assert(is_same<decltype(ta->i16()), int16_t>::value, "invalid type");
static_assert(is_same<decltype(ta->i32()), int32_t>::value, "invalid type");
@@ -2685,14 +3094,16 @@
flatbuffers::FlatBufferBuilder builder;
Test *buf = nullptr;
- auto vector_offset = builder.CreateUninitializedVectorOfStructs<Test>(2, &buf);
+ auto vector_offset =
+ builder.CreateUninitializedVectorOfStructs<Test>(2, &buf);
TEST_NOTNULL(buf);
buf[0] = Test(10, 20);
buf[1] = Test(30, 40);
auto required_name = builder.CreateString("myMonster");
auto monster_builder = MonsterBuilder(builder);
- monster_builder.add_name(required_name); // required field mandated for monster.
+ monster_builder.add_name(
+ required_name); // required field mandated for monster.
monster_builder.add_test4(vector_offset);
builder.Finish(monster_builder.Finish());
@@ -2737,11 +3148,11 @@
// For testing any binaries, e.g. from fuzzing.
void LoadVerifyBinaryTest() {
std::string binary;
- if (flatbuffers::LoadFile((test_data_path +
- "fuzzer/your-filename-here").c_str(),
- true, &binary)) {
+ if (flatbuffers::LoadFile(
+ (test_data_path + "fuzzer/your-filename-here").c_str(), true,
+ &binary)) {
flatbuffers::Verifier verifier(
- reinterpret_cast<const uint8_t *>(binary.data()), binary.size());
+ reinterpret_cast<const uint8_t *>(binary.data()), binary.size());
TEST_EQ(VerifyMonsterBuffer(verifier), true);
}
}
@@ -2757,24 +3168,28 @@
TEST_EQ(onetwo.o != two.o, true);
// Support for embedded nulls
- const char chars_b[] = {'a', '\0', 'b'};
- const char chars_c[] = {'a', '\0', 'c'};
+ const char chars_b[] = { 'a', '\0', 'b' };
+ const char chars_c[] = { 'a', '\0', 'c' };
const auto null_b1 = builder.CreateSharedString(chars_b, sizeof(chars_b));
const auto null_c = builder.CreateSharedString(chars_c, sizeof(chars_c));
const auto null_b2 = builder.CreateSharedString(chars_b, sizeof(chars_b));
- TEST_EQ(null_b1.o != null_c.o, true); // Issue#5058 repro
+ TEST_EQ(null_b1.o != null_c.o, true); // Issue#5058 repro
TEST_EQ(null_b1.o, null_b2.o);
// Put the strings into an array for round trip verification.
- const flatbuffers::Offset<flatbuffers::String> array[7] = { one1, two, one2, onetwo, null_b1, null_c, null_b2 };
- const auto vector_offset = builder.CreateVector(array, flatbuffers::uoffset_t(7));
+ const flatbuffers::Offset<flatbuffers::String> array[7] = {
+ one1, two, one2, onetwo, null_b1, null_c, null_b2
+ };
+ const auto vector_offset =
+ builder.CreateVector(array, flatbuffers::uoffset_t(7));
MonsterBuilder monster_builder(builder);
monster_builder.add_name(two);
monster_builder.add_testarrayofstring(vector_offset);
builder.Finish(monster_builder.Finish());
// Read the Monster back.
- const auto *monster = flatbuffers::GetRoot<Monster>(builder.GetBufferPointer());
+ const auto *monster =
+ flatbuffers::GetRoot<Monster>(builder.GetBufferPointer());
TEST_EQ_STR(monster->name()->c_str(), "two");
const auto *testarrayofstring = monster->testarrayofstring();
TEST_EQ(testarrayofstring->size(), flatbuffers::uoffset_t(7));
@@ -2787,7 +3202,8 @@
TEST_EQ(a[5]->str(), (std::string(chars_c, sizeof(chars_c))));
TEST_EQ(a[6]->str(), (std::string(chars_b, sizeof(chars_b))));
- // Make sure String::operator< works, too, since it is related to StringOffsetCompare.
+ // Make sure String::operator< works, too, since it is related to
+ // StringOffsetCompare.
TEST_EQ((*a[0]) < (*a[1]), true);
TEST_EQ((*a[1]) < (*a[0]), false);
TEST_EQ((*a[1]) < (*a[2]), false);
@@ -2798,6 +3214,89 @@
TEST_EQ((*a[6]) < (*a[5]), true);
}
+#if !defined(FLATBUFFERS_SPAN_MINIMAL)
+void FlatbuffersSpanTest() {
+ // Compile-time checking of non-const [] to const [] conversions.
+ using flatbuffers::internal::is_span_convertable;
+ (void)is_span_convertable<int, 1, int, 1>::type(123);
+ (void)is_span_convertable<const int, 1, int, 1>::type(123);
+ (void)is_span_convertable<const int64_t, 1, int64_t, 1>::type(123);
+ (void)is_span_convertable<const uint64_t, 1, uint64_t, 1>::type(123);
+ (void)is_span_convertable<const int, 1, const int, 1>::type(123);
+ (void)is_span_convertable<const int64_t, 1, const int64_t, 1>::type(123);
+ (void)is_span_convertable<const uint64_t, 1, const uint64_t, 1>::type(123);
+
+ using flatbuffers::span;
+ span<char, 0> c1;
+ TEST_EQ(c1.size(), 0);
+ span<char, flatbuffers::dynamic_extent> c2;
+ TEST_EQ(c2.size(), 0);
+ span<char> c3;
+ TEST_EQ(c3.size(), 0);
+ TEST_ASSERT(c1.empty() && c2.empty() && c3.empty());
+
+ int i_data7[7] = { 0, 1, 2, 3, 4, 5, 6 };
+ span<int, 7> i1(&i_data7[0], 7);
+ span<int> i2(i1); // make dynamic from static
+ TEST_EQ(i1.size(), 7);
+ TEST_EQ(i1.empty(), false);
+ TEST_EQ(i1.size(), i2.size());
+ TEST_EQ(i1.data(), i_data7);
+ TEST_EQ(i1[2], 2);
+ // Make const span from a non-const one.
+ span<const int, 7> i3(i1);
+ // Construct from a C-array.
+ span<int, 7> i4(i_data7);
+ span<const int, 7> i5(i_data7);
+ span<int> i6(i_data7);
+ span<const int> i7(i_data7);
+ TEST_EQ(i7.size(), 7);
+ // Check construction from a const array.
+ const int i_cdata5[5] = { 4, 3, 2, 1, 0 };
+ span<const int, 5> i8(i_cdata5);
+ span<const int> i9(i_cdata5);
+ TEST_EQ(i9.size(), 5);
+ // Construction from a (ptr, size) pair.
+ span<int, 7> i10(i_data7, 7);
+ span<int> i11(i_data7, 7);
+ TEST_EQ(i11.size(), 7);
+ span<const int, 5> i12(i_cdata5, 5);
+ span<const int> i13(i_cdata5, 5);
+ TEST_EQ(i13.size(), 5);
+ // Construction from std::array.
+ std::array<int, 6> i_arr6 = { { 0, 1, 2, 3, 4, 5 } };
+ span<int, 6> i14(i_arr6);
+ span<const int, 6> i15(i_arr6);
+ span<int> i16(i_arr6);
+ span<const int> i17(i_arr6);
+ TEST_EQ(i17.size(), 6);
+ const std::array<int, 8> i_carr8 = { { 0, 1, 2, 3, 4, 5, 6, 7 } };
+ span<const int, 8> i18(i_carr8);
+ span<const int> i19(i_carr8);
+ TEST_EQ(i18.size(), 8);
+ TEST_EQ(i19.size(), 8);
+ TEST_EQ(i19[7], 7);
+ // Check compatibility with flatbuffers::Array.
+ int fbs_int3_underlaying[3] = { 0 };
+ int fbs_int3_data[3] = { 1, 2, 3 };
+ auto &fbs_int3 = flatbuffers::CastToArray(fbs_int3_underlaying);
+ fbs_int3.CopyFromSpan(fbs_int3_data);
+ TEST_EQ(fbs_int3.Get(1), 2);
+ const int fbs_cint3_data[3] = { 2, 3, 4 };
+ fbs_int3.CopyFromSpan(fbs_cint3_data);
+ TEST_EQ(fbs_int3.Get(1), 3);
+ // Check with Array<Enum, N>
+ enum class Dummy : uint16_t { Zero = 0, One, Two };
+ Dummy fbs_dummy3_underlaying[3] = {};
+ Dummy fbs_dummy3_data[3] = { Dummy::One, Dummy::Two, Dummy::Two };
+ auto &fbs_dummy3 = flatbuffers::CastToArray(fbs_dummy3_underlaying);
+ fbs_dummy3.CopyFromSpan(fbs_dummy3_data);
+ TEST_EQ(fbs_dummy3.Get(1), Dummy::Two);
+}
+#else
+void FlatbuffersSpanTest() {}
+#endif
+
void FixedLengthArrayTest() {
// VS10 does not support typed enums, exclude from tests
#if !defined(_MSC_VER) || _MSC_VER >= 1700
@@ -2810,6 +3309,9 @@
TEST_NOTNULL(nStruct0.mutable_c());
nStruct0.mutable_c()->Mutate(0, MyGame::Example::TestEnum::C);
nStruct0.mutable_c()->Mutate(1, MyGame::Example::TestEnum::A);
+ TEST_NOTNULL(nStruct0.mutable_d());
+ nStruct0.mutable_d()->Mutate(0, flatbuffers::numeric_limits<int64_t>::max());
+ nStruct0.mutable_d()->Mutate(1, flatbuffers::numeric_limits<int64_t>::min());
MyGame::Example::NestedStruct nStruct1(MyGame::Example::TestEnum::C);
TEST_NOTNULL(nStruct1.mutable_a());
nStruct1.mutable_a()->Mutate(0, 3);
@@ -2817,16 +3319,20 @@
TEST_NOTNULL(nStruct1.mutable_c());
nStruct1.mutable_c()->Mutate(0, MyGame::Example::TestEnum::C);
nStruct1.mutable_c()->Mutate(1, MyGame::Example::TestEnum::A);
- MyGame::Example::ArrayStruct aStruct(2, 12);
+ TEST_NOTNULL(nStruct1.mutable_d());
+ nStruct1.mutable_d()->Mutate(0, flatbuffers::numeric_limits<int64_t>::min());
+ nStruct1.mutable_d()->Mutate(1, flatbuffers::numeric_limits<int64_t>::max());
+ MyGame::Example::ArrayStruct aStruct(2, 12, 1);
TEST_NOTNULL(aStruct.b());
TEST_NOTNULL(aStruct.mutable_b());
TEST_NOTNULL(aStruct.mutable_d());
+ TEST_NOTNULL(aStruct.mutable_f());
for (int i = 0; i < aStruct.b()->size(); i++)
aStruct.mutable_b()->Mutate(i, i + 1);
aStruct.mutable_d()->Mutate(0, nStruct0);
aStruct.mutable_d()->Mutate(1, nStruct1);
auto aTable = MyGame::Example::CreateArrayTable(fbb, &aStruct);
- fbb.Finish(aTable);
+ MyGame::Example::FinishArrayTableBuffer(fbb, aTable);
// Verify correctness of the ArrayTable.
flatbuffers::Verifier verifier(fbb.GetBufferPointer(), fbb.GetSize());
@@ -2836,40 +3342,120 @@
TEST_NOTNULL(mArStruct);
TEST_NOTNULL(mArStruct->b());
TEST_NOTNULL(mArStruct->d());
+ TEST_NOTNULL(mArStruct->f());
TEST_NOTNULL(mArStruct->mutable_b());
TEST_NOTNULL(mArStruct->mutable_d());
+ TEST_NOTNULL(mArStruct->mutable_f());
mArStruct->mutable_b()->Mutate(14, -14);
TEST_EQ(mArStruct->a(), 2);
TEST_EQ(mArStruct->b()->size(), 15);
TEST_EQ(mArStruct->b()->Get(aStruct.b()->size() - 1), -14);
TEST_EQ(mArStruct->c(), 12);
- TEST_NOTNULL(mArStruct->d()->Get(0).a());
- TEST_EQ(mArStruct->d()->Get(0).a()->Get(0), 1);
- TEST_EQ(mArStruct->d()->Get(0).a()->Get(1), 2);
- TEST_NOTNULL(mArStruct->d()->Get(1).a());
- TEST_EQ(mArStruct->d()->Get(1).a()->Get(0), 3);
- TEST_EQ(mArStruct->d()->Get(1).a()->Get(1), 4);
+ TEST_NOTNULL(mArStruct->d()->Get(0));
+ TEST_NOTNULL(mArStruct->d()->Get(0)->a());
+ TEST_EQ(mArStruct->d()->Get(0)->a()->Get(0), 1);
+ TEST_EQ(mArStruct->d()->Get(0)->a()->Get(1), 2);
+ TEST_NOTNULL(mArStruct->d()->Get(1));
+ TEST_NOTNULL(mArStruct->d()->Get(1)->a());
+ TEST_EQ(mArStruct->d()->Get(1)->a()->Get(0), 3);
+ TEST_EQ(mArStruct->d()->Get(1)->a()->Get(1), 4);
TEST_NOTNULL(mArStruct->mutable_d()->GetMutablePointer(1));
TEST_NOTNULL(mArStruct->mutable_d()->GetMutablePointer(1)->mutable_a());
mArStruct->mutable_d()->GetMutablePointer(1)->mutable_a()->Mutate(1, 5);
- TEST_EQ(mArStruct->d()->Get(1).a()->Get(1), 5);
- TEST_EQ(mArStruct->d()->Get(0).b() == MyGame::Example::TestEnum::B, true);
- TEST_NOTNULL(mArStruct->d()->Get(0).c());
- TEST_EQ(mArStruct->d()->Get(0).c()->Get(0) == MyGame::Example::TestEnum::C,
- true);
- TEST_EQ(mArStruct->d()->Get(0).c()->Get(1) == MyGame::Example::TestEnum::A,
- true);
- TEST_EQ(mArStruct->d()->Get(1).b() == MyGame::Example::TestEnum::C, true);
- TEST_NOTNULL(mArStruct->d()->Get(1).c());
- TEST_EQ(mArStruct->d()->Get(1).c()->Get(0) == MyGame::Example::TestEnum::C,
- true);
- TEST_EQ(mArStruct->d()->Get(1).c()->Get(1) == MyGame::Example::TestEnum::A,
- true);
+ TEST_EQ(5, mArStruct->d()->Get(1)->a()->Get(1));
+ TEST_EQ(MyGame::Example::TestEnum::B, mArStruct->d()->Get(0)->b());
+ TEST_NOTNULL(mArStruct->d()->Get(0)->c());
+ TEST_EQ(MyGame::Example::TestEnum::C, mArStruct->d()->Get(0)->c()->Get(0));
+ TEST_EQ(MyGame::Example::TestEnum::A, mArStruct->d()->Get(0)->c()->Get(1));
+ TEST_EQ(flatbuffers::numeric_limits<int64_t>::max(),
+ mArStruct->d()->Get(0)->d()->Get(0));
+ TEST_EQ(flatbuffers::numeric_limits<int64_t>::min(),
+ mArStruct->d()->Get(0)->d()->Get(1));
+ TEST_EQ(MyGame::Example::TestEnum::C, mArStruct->d()->Get(1)->b());
+ TEST_NOTNULL(mArStruct->d()->Get(1)->c());
+ TEST_EQ(MyGame::Example::TestEnum::C, mArStruct->d()->Get(1)->c()->Get(0));
+ TEST_EQ(MyGame::Example::TestEnum::A, mArStruct->d()->Get(1)->c()->Get(1));
+ TEST_EQ(flatbuffers::numeric_limits<int64_t>::min(),
+ mArStruct->d()->Get(1)->d()->Get(0));
+ TEST_EQ(flatbuffers::numeric_limits<int64_t>::max(),
+ mArStruct->d()->Get(1)->d()->Get(1));
for (int i = 0; i < mArStruct->b()->size() - 1; i++)
TEST_EQ(mArStruct->b()->Get(i), i + 1);
+ // Check alignment
+ TEST_EQ(0, reinterpret_cast<uintptr_t>(mArStruct->d()) % 8);
+ TEST_EQ(0, reinterpret_cast<uintptr_t>(mArStruct->f()) % 8);
+
+ // Check if default constructor set all memory zero
+ const size_t arr_size = sizeof(MyGame::Example::ArrayStruct);
+ char non_zero_memory[arr_size];
+ // set memory chunk of size ArrayStruct to 1's
+ std::memset(static_cast<void *>(non_zero_memory), 1, arr_size);
+ // after placement-new it should be all 0's
+#if defined (_MSC_VER) && defined (_DEBUG)
+ #undef new
+#endif
+ MyGame::Example::ArrayStruct *ap = new (non_zero_memory) MyGame::Example::ArrayStruct;
+#if defined (_MSC_VER) && defined (_DEBUG)
+ #define new DEBUG_NEW
+#endif
+ (void)ap;
+ for (size_t i = 0; i < arr_size; ++i) {
+ TEST_EQ(non_zero_memory[i], 0);
+ }
#endif
}
+#if !defined(FLATBUFFERS_SPAN_MINIMAL) && (!defined(_MSC_VER) || _MSC_VER >= 1700)
+void FixedLengthArrayConstructorTest() {
+ const int32_t nested_a[2] = { 1, 2 };
+ MyGame::Example::TestEnum nested_c[2] = { MyGame::Example::TestEnum::A,
+ MyGame::Example::TestEnum::B };
+ const int64_t int64_2[2] = { -2, -1 };
+
+ std::array<MyGame::Example::NestedStruct, 2> init_d = {
+ { MyGame::Example::NestedStruct(nested_a, MyGame::Example::TestEnum::B,
+ nested_c, int64_2),
+ MyGame::Example::NestedStruct(nested_a, MyGame::Example::TestEnum::A,
+ nested_c,
+ std::array<int64_t, 2>{ { 12, 13 } }) }
+ };
+
+ MyGame::Example::ArrayStruct arr_struct(
+ 8.125,
+ std::array<int32_t, 0xF>{
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } },
+ -17, init_d, 10, int64_2);
+ TEST_EQ(arr_struct.a(), 8.125);
+ TEST_EQ(arr_struct.b()->Get(2), 3);
+ TEST_EQ(arr_struct.c(), -17);
+
+ TEST_NOTNULL(arr_struct.d());
+ const auto &arr_d_0 = *arr_struct.d()->Get(0);
+ TEST_EQ(arr_d_0.a()->Get(0), 1);
+ TEST_EQ(arr_d_0.a()->Get(1), 2);
+ TEST_EQ(arr_d_0.b(), MyGame::Example::TestEnum::B);
+ TEST_EQ(arr_d_0.c()->Get(0), MyGame::Example::TestEnum::A);
+ TEST_EQ(arr_d_0.c()->Get(1), MyGame::Example::TestEnum::B);
+ TEST_EQ(arr_d_0.d()->Get(0), -2);
+ TEST_EQ(arr_d_0.d()->Get(1), -1);
+ const auto &arr_d_1 = *arr_struct.d()->Get(1);
+ TEST_EQ(arr_d_1.a()->Get(0), 1);
+ TEST_EQ(arr_d_1.a()->Get(1), 2);
+ TEST_EQ(arr_d_1.b(), MyGame::Example::TestEnum::A);
+ TEST_EQ(arr_d_1.c()->Get(0), MyGame::Example::TestEnum::A);
+ TEST_EQ(arr_d_1.c()->Get(1), MyGame::Example::TestEnum::B);
+ TEST_EQ(arr_d_1.d()->Get(0), 12);
+ TEST_EQ(arr_d_1.d()->Get(1), 13);
+
+ TEST_EQ(arr_struct.e(), 10);
+ TEST_EQ(arr_struct.f()->Get(0), -2);
+ TEST_EQ(arr_struct.f()->Get(1), -1);
+}
+#else
+void FixedLengthArrayConstructorTest() {
+}
+#endif
+
void NativeTypeTest() {
const int N = 3;
@@ -2877,23 +3463,24 @@
src_data.vectors.reserve(N);
for (int i = 0; i < N; ++i) {
- src_data.vectors.push_back (Native::Vector3D(10 * i + 0.1f, 10 * i + 0.2f, 10 * i + 0.3f));
+ src_data.vectors.push_back(
+ Native::Vector3D(10 * i + 0.1f, 10 * i + 0.2f, 10 * i + 0.3f));
}
flatbuffers::FlatBufferBuilder fbb;
fbb.Finish(Geometry::ApplicationData::Pack(fbb, &src_data));
- auto dstDataT = Geometry::UnPackApplicationData(fbb.GetBufferPointer());
+ auto dstDataT = Geometry::UnPackApplicationData(fbb.GetBufferPointer());
for (int i = 0; i < N; ++i) {
- Native::Vector3D& v = dstDataT->vectors[i];
+ Native::Vector3D &v = dstDataT->vectors[i];
TEST_EQ(v.x, 10 * i + 0.1f);
TEST_EQ(v.y, 10 * i + 0.2f);
TEST_EQ(v.z, 10 * i + 0.3f);
}
}
-void FixedLengthArrayJsonTest(bool binary) {
+void FixedLengthArrayJsonTest(bool binary) {
// VS10 does not support typed enums, exclude from tests
#if !defined(_MSC_VER) || _MSC_VER >= 1700
// load FlatBuffer schema (.fbs) and JSON from disk
@@ -2957,6 +3544,172 @@
#endif
}
+void TestEmbeddedBinarySchema() {
+ // load JSON from disk
+ std::string jsonfile;
+ TEST_EQ(flatbuffers::LoadFile(
+ (test_data_path + "monsterdata_test.golden").c_str(), false,
+ &jsonfile),
+ true);
+
+ // parse schema first, so we can use it to parse the data after
+ flatbuffers::Parser parserOrg, parserGen;
+ flatbuffers::Verifier verifier(MyGame::Example::MonsterBinarySchema::data(),
+ MyGame::Example::MonsterBinarySchema::size());
+ TEST_EQ(reflection::VerifySchemaBuffer(verifier), true);
+ TEST_EQ(parserOrg.Deserialize(MyGame::Example::MonsterBinarySchema::data(),
+ MyGame::Example::MonsterBinarySchema::size()),
+ true);
+ TEST_EQ(parserGen.Deserialize(MyGame::Example::MonsterBinarySchema::data(),
+ MyGame::Example::MonsterBinarySchema::size()),
+ true);
+ TEST_EQ(parserOrg.Parse(jsonfile.c_str()), true);
+
+ // First, verify it, just in case:
+ flatbuffers::Verifier verifierOrg(parserOrg.builder_.GetBufferPointer(),
+ parserOrg.builder_.GetSize());
+ TEST_EQ(VerifyMonsterBuffer(verifierOrg), true);
+
+ // Export to JSON
+ std::string jsonGen;
+ TEST_EQ(
+ GenerateText(parserOrg, parserOrg.builder_.GetBufferPointer(), &jsonGen),
+ true);
+
+ // Import from JSON
+ TEST_EQ(parserGen.Parse(jsonGen.c_str()), true);
+
+ // Verify buffer from generated JSON
+ flatbuffers::Verifier verifierGen(parserGen.builder_.GetBufferPointer(),
+ parserGen.builder_.GetSize());
+ TEST_EQ(VerifyMonsterBuffer(verifierGen), true);
+
+ // Compare generated buffer to original
+ TEST_EQ(parserOrg.builder_.GetSize(), parserGen.builder_.GetSize());
+ TEST_EQ(std::memcmp(parserOrg.builder_.GetBufferPointer(),
+ parserGen.builder_.GetBufferPointer(),
+ parserOrg.builder_.GetSize()),
+ 0);
+}
+
+void OptionalScalarsTest() {
+ // Simple schemas and a "has optional scalar" sentinal.
+ std::vector<std::string> schemas;
+ schemas.push_back("table Monster { mana : int; }");
+ schemas.push_back("table Monster { mana : int = 42; }");
+ schemas.push_back("table Monster { mana : int = null; }");
+ schemas.push_back("table Monster { mana : long; }");
+ schemas.push_back("table Monster { mana : long = 42; }");
+ schemas.push_back("table Monster { mana : long = null; }");
+ schemas.push_back("table Monster { mana : float; }");
+ schemas.push_back("table Monster { mana : float = 42; }");
+ schemas.push_back("table Monster { mana : float = null; }");
+ schemas.push_back("table Monster { mana : double; }");
+ schemas.push_back("table Monster { mana : double = 42; }");
+ schemas.push_back("table Monster { mana : double = null; }");
+ schemas.push_back("table Monster { mana : bool; }");
+ schemas.push_back("table Monster { mana : bool = 42; }");
+ schemas.push_back("table Monster { mana : bool = null; }");
+ schemas.push_back("enum Enum: int {A=0, B=1} "
+ "table Monster { mana : Enum; }");
+ schemas.push_back("enum Enum: int {A=0, B=1} "
+ "table Monster { mana : Enum = B; }");
+ schemas.push_back("enum Enum: int {A=0, B=1} "
+ "table Monster { mana : Enum = null; }");
+
+ // Check the FieldDef is correctly set.
+ for (auto schema = schemas.begin(); schema < schemas.end(); schema++) {
+ const bool has_null = schema->find("null") != std::string::npos;
+ flatbuffers::Parser parser;
+ TEST_ASSERT(parser.Parse(schema->c_str()));
+ const auto *mana = parser.structs_.Lookup("Monster")->fields.Lookup("mana");
+ TEST_EQ(mana->optional, has_null);
+ }
+
+ // Test if nullable scalars are allowed for each language.
+ for (unsigned lang = 1; lang < flatbuffers::IDLOptions::kMAX; lang <<= 1) {
+ flatbuffers::IDLOptions opts;
+ opts.lang_to_generate = lang;
+ if (false == flatbuffers::Parser::SupportsOptionalScalars(opts)) {
+ continue;
+ }
+ for (auto schema = schemas.begin(); schema < schemas.end(); schema++) {
+ flatbuffers::Parser parser(opts);
+ auto done = parser.Parse(schema->c_str());
+ TEST_EQ_STR(parser.error_.c_str(), "");
+ TEST_ASSERT(done);
+ }
+ }
+
+ // test C++ nullable
+ flatbuffers::FlatBufferBuilder fbb;
+ FinishScalarStuffBuffer(
+ fbb, optional_scalars::CreateScalarStuff(fbb, 1, static_cast<int8_t>(2)));
+ auto opts = optional_scalars::GetMutableScalarStuff(fbb.GetBufferPointer());
+ TEST_ASSERT(!opts->maybe_bool());
+ TEST_ASSERT(!opts->maybe_f32().has_value());
+ TEST_ASSERT(opts->maybe_i8().has_value());
+ TEST_EQ(opts->maybe_i8().value(), 2);
+ TEST_ASSERT(opts->mutate_maybe_i8(3));
+ TEST_ASSERT(opts->maybe_i8().has_value());
+ TEST_EQ(opts->maybe_i8().value(), 3);
+ TEST_ASSERT(!opts->mutate_maybe_i16(-10));
+
+ optional_scalars::ScalarStuffT obj;
+ TEST_ASSERT(!obj.maybe_bool);
+ TEST_ASSERT(!obj.maybe_f32.has_value());
+ opts->UnPackTo(&obj);
+ TEST_ASSERT(!obj.maybe_bool);
+ TEST_ASSERT(!obj.maybe_f32.has_value());
+ TEST_ASSERT(obj.maybe_i8.has_value() && obj.maybe_i8.value() == 3);
+ TEST_ASSERT(obj.maybe_i8 && *obj.maybe_i8 == 3);
+ obj.maybe_i32 = -1;
+ obj.maybe_enum = optional_scalars::OptionalByte_Two;
+
+ fbb.Clear();
+ FinishScalarStuffBuffer(fbb, optional_scalars::ScalarStuff::Pack(fbb, &obj));
+ opts = optional_scalars::GetMutableScalarStuff(fbb.GetBufferPointer());
+ TEST_ASSERT(opts->maybe_i8().has_value());
+ TEST_EQ(opts->maybe_i8().value(), 3);
+ TEST_ASSERT(opts->maybe_i32().has_value());
+ TEST_EQ(opts->maybe_i32().value(), -1);
+ TEST_EQ(opts->maybe_enum().value(), optional_scalars::OptionalByte_Two);
+ TEST_ASSERT(opts->maybe_i32() == flatbuffers::Optional<int64_t>(-1));
+}
+
+void ParseFlexbuffersFromJsonWithNullTest() {
+ // Test nulls are handled appropriately through flexbuffers to exercise other
+ // code paths of ParseSingleValue in the optional scalars change.
+ // TODO(cneo): Json -> Flatbuffers test once some language can generate code
+ // with optional scalars.
+ {
+ char json[] = "{\"opt_field\": 123 }";
+ flatbuffers::Parser parser;
+ flexbuffers::Builder flexbuild;
+ parser.ParseFlexBuffer(json, nullptr, &flexbuild);
+ auto root = flexbuffers::GetRoot(flexbuild.GetBuffer());
+ TEST_EQ(root.AsMap()["opt_field"].AsInt64(), 123);
+ }
+ {
+ char json[] = "{\"opt_field\": 123.4 }";
+ flatbuffers::Parser parser;
+ flexbuffers::Builder flexbuild;
+ parser.ParseFlexBuffer(json, nullptr, &flexbuild);
+ auto root = flexbuffers::GetRoot(flexbuild.GetBuffer());
+ TEST_EQ(root.AsMap()["opt_field"].AsDouble(), 123.4);
+ }
+ {
+ char json[] = "{\"opt_field\": null }";
+ flatbuffers::Parser parser;
+ flexbuffers::Builder flexbuild;
+ parser.ParseFlexBuffer(json, nullptr, &flexbuild);
+ auto root = flexbuffers::GetRoot(flexbuild.GetBuffer());
+ TEST_ASSERT(!root.AsMap().IsTheEmptyMap());
+ TEST_ASSERT(root.AsMap()["opt_field"].IsNull());
+ TEST_EQ(root.ToString(), std::string("{ opt_field: null }"));
+ }
+}
+
int FlatBufferTests() {
// clang-format off
@@ -2981,6 +3734,7 @@
ObjectFlatBuffersTest(flatbuf.data());
MiniReflectFlatBuffersTest(flatbuf.data());
+ MiniReflectFixedLengthArrayTest();
SizePrefixedTest();
@@ -2995,9 +3749,14 @@
FixedLengthArrayJsonTest(true);
ReflectionTest(flatbuf.data(), flatbuf.size());
ParseProtoTest();
+ ParseProtoTestWithSuffix();
+ ParseProtoTestWithIncludes();
+ EvolutionTest();
+ UnionDeprecationTest();
UnionVectorTest();
LoadVerifyBinaryTest();
GenerateTableTextTest();
+ TestEmbeddedBinarySchema();
#endif
// clang-format on
@@ -3029,6 +3788,7 @@
JsonDefaultTest();
JsonEnumsTest();
FlexBuffersTest();
+ FlexBuffersDeprecatedTest();
UninitializedVectorTest();
EqualOperatorTest();
NumericUtilsTest();
@@ -3038,10 +3798,14 @@
TestMonsterExtraFloats();
FixedLengthArrayTest();
NativeTypeTest();
+ OptionalScalarsTest();
+ ParseFlexbuffersFromJsonWithNullTest();
+ FlatbuffersSpanTest();
+ FixedLengthArrayConstructorTest();
return 0;
}
-int main(int /*argc*/, const char * /*argv*/ []) {
+int main(int /*argc*/, const char * /*argv*/[]) {
InitTestEngine();
std::string req_locale;