#include <stdint.h>
#include <cmath>
#include <limits>
#include <memory>
#include <string>
#if defined(__ANDROID__)
#define INCLUDE_64_BIT_TESTS …
#else
#define INCLUDE_64_BIT_TESTS …
#endif
#include "alignment_test.h"
#include "evolution_test.h"
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/idl.h"
#include "flatbuffers/minireflect.h"
#include "flatbuffers/reflection_generated.h"
#include "flatbuffers/registry.h"
#include "flatbuffers/util.h"
#include "fuzz_test.h"
#include "json_test.h"
#include "key_field_test.h"
#include "monster_test.h"
#include "monster_test_generated.h"
#include "native_inline_table_test_generated.h"
#include "optional_scalars_test.h"
#include "parser_test.h"
#include "proto_test.h"
#include "reflection_test.h"
#include "tests/union_vector/union_vector_generated.h"
#include "union_underlying_type_test_generated.h"
#if !defined(_MSC_VER) || _MSC_VER >= 1700
# include "tests/arrays_test_generated.h"
#endif
#if INCLUDE_64_BIT_TESTS
#include "tests/64bit/offset64_test.h"
#endif
#include "flexbuffers_test.h"
#include "is_quiet_nan.h"
#include "monster_test_bfbs_generated.h"
#include "native_type_test_generated.h"
#include "test_assert.h"
#include "util_test.h"
void FlatBufferBuilderTest();
namespace flatbuffers {
namespace tests {
namespace {
static_assert …;
#if defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
static_assert …;
#endif
usingnamespaceMyGame::Example;
void TriviallyCopyableTest() { … }
#ifndef FLATBUFFERS_NO_FILE_TESTS
void GenerateTableTextTest(const std::string &tests_data_path) { … }
void MultiFileNameClashTest(const std::string &tests_data_path) { … }
void InvalidNestedFlatbufferTest(const std::string &tests_data_path) { … }
void UnionVectorTest(const std::string &tests_data_path) { … }
#endif
void EndianSwapTest() { … }
void UninitializedVectorTest() { … }
void EqualOperatorTest() { … }
void CreateSharedStringTest() { … }
#if !defined(FLATBUFFERS_USE_STD_SPAN) && !defined(FLATBUFFERS_SPAN_MINIMAL)
void FlatbuffersSpanTest() {
using flatbuffers::internal::is_span_convertible;
(void)is_span_convertible<int, 1, int, 1>::type(123);
(void)is_span_convertible<const int, 1, int, 1>::type(123);
(void)is_span_convertible<const int64_t, 1, int64_t, 1>::type(123);
(void)is_span_convertible<const uint64_t, 1, uint64_t, 1>::type(123);
(void)is_span_convertible<const int, 1, const int, 1>::type(123);
(void)is_span_convertible<const int64_t, 1, const int64_t, 1>::type(123);
(void)is_span_convertible<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);
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);
span<const int, 7> i3(i1);
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);
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);
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);
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);
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);
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
#if !defined(_MSC_VER) || _MSC_VER >= 1700
void FixedLengthArrayTest() { … }
#else
void FixedLengthArrayTest() {}
#endif
#if !defined(FLATBUFFERS_SPAN_MINIMAL) && \
(!defined(_MSC_VER) || _MSC_VER >= 1700)
void FixedLengthArrayConstructorTest() { … }
#else
void FixedLengthArrayConstructorTest() {}
#endif
void FixedLengthArrayOperatorEqualTest() { … }
void NativeTypeTest() { … }
#ifndef FLATBUFFERS_NO_FILE_TESTS
# if !defined(_MSC_VER) || _MSC_VER >= 1700
void FixedLengthArrayJsonTest(const std::string &tests_data_path, bool binary) { … }
void FixedLengthArraySpanTest(const std::string &tests_data_path) { … }
# else
void FixedLengthArrayJsonTest(bool ) {}
void FixedLengthArraySpanTest() {}
# endif
void TestEmbeddedBinarySchema(const std::string &tests_data_path) { … }
#endif
template<typename T> void EmbeddedSchemaAccessByType() { … }
void EmbeddedSchemaAccess() { … }
void NestedVerifierTest() { … }
template<class T, class Container>
void TestIterators(const std::vector<T> &expected, const Container &tested) { … }
void FlatbuffersIteratorsTest() { … }
void PrivateAnnotationsLeaks() { … }
void VectorSpanTest() { … }
void NativeInlineTableVectorTest() { … }
#ifndef FLATBUFFERS_NO_FILE_TESTS
void DoNotRequireEofTest(const std::string &tests_data_path) { … }
#endif
void UnionUnderlyingTypeTest() { … }
static void Offset64Tests() { … }
int FlatBufferTests(const std::string &tests_data_path) { … }
}
}
}
int main(int argc, const char *argv[]) { … }