#include "fuzz_test.h" #include <algorithm> #include "flatbuffers/flatbuffers.h" #include "flatbuffers/idl.h" #include "test_assert.h" namespace flatbuffers { namespace tests { namespace { // Include simple random number generator to ensure results will be the // same cross platform. // http://en.wikipedia.org/wiki/Park%E2%80%93Miller_random_number_generator uint32_t lcg_seed = …; uint32_t lcg_rand() { … } void lcg_reset() { … } template<typename T> static void CompareTableFieldValue(flatbuffers::Table *table, flatbuffers::voffset_t voffset, T val) { … } } // namespace // Low level stress/fuzz test: serialize/deserialize a variety of // different kinds of data in different combinations void FuzzTest1() { … } // High level stress/fuzz test: generate a big schema and // matching json data in random combinations, then parse both, // generate json back from the binary, and compare with the original. void FuzzTest2() { … } } // namespace tests } // namespace flatbuffers