mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-28 01:08:04 +00:00
run scripts/clang-format-all.sh
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "alignment_test.h"
|
||||
|
||||
#include "flatbuffers/flatbuffer_builder.h"
|
||||
#include "alignment_test_generated.h"
|
||||
#include "flatbuffers/flatbuffer_builder.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
@@ -16,7 +16,7 @@ void AlignmentTest() {
|
||||
BadAlignmentSmall *small;
|
||||
Offset<Vector<const BadAlignmentSmall *>> small_offset =
|
||||
builder.CreateUninitializedVectorOfStructs(9, &small);
|
||||
(void)small; // We do not have to write data to trigger the test failure
|
||||
(void)small; // We do not have to write data to trigger the test failure
|
||||
|
||||
Offset<BadAlignmentRoot> root =
|
||||
CreateBadAlignmentRoot(builder, outer_large, small_offset);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <limits>
|
||||
|
||||
#include "flexbuffers_test.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "flatbuffers/flexbuffers.h"
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "is_quiet_nan.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "fuzz_test.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "test_assert.h"
|
||||
@@ -22,7 +22,7 @@ void lcg_reset() { lcg_seed = 48271; }
|
||||
|
||||
template<typename T>
|
||||
static void CompareTableFieldValue(flatbuffers::Table *table,
|
||||
flatbuffers::voffset_t voffset, T val) {
|
||||
flatbuffers::voffset_t voffset, T val) {
|
||||
T read = table->GetField(voffset, static_cast<T>(0));
|
||||
TEST_EQ(read, val);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "monster_test_bfbs_generated.h"
|
||||
#include "monster_test_generated.h"
|
||||
#include "monster_test_bfbs_generated.h"
|
||||
#include "optional_scalars_generated.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace tests {
|
||||
using namespace MyGame::Example;
|
||||
|
||||
// Check stringify of an default enum value to json
|
||||
void JsonDefaultTest(const std::string& tests_data_path) {
|
||||
void JsonDefaultTest(const std::string &tests_data_path) {
|
||||
// load FlatBuffer schema (.fbs) from disk
|
||||
std::string schemafile;
|
||||
TEST_EQ(flatbuffers::LoadFile((tests_data_path + "monster_test.fbs").c_str(),
|
||||
@@ -44,7 +44,7 @@ void JsonDefaultTest(const std::string& tests_data_path) {
|
||||
TEST_EQ(std::string::npos != jsongen.find("testf: 3.14159"), true);
|
||||
}
|
||||
|
||||
void JsonEnumsTest(const std::string& tests_data_path) {
|
||||
void JsonEnumsTest(const std::string &tests_data_path) {
|
||||
// load FlatBuffer schema (.fbs) from disk
|
||||
std::string schemafile;
|
||||
TEST_EQ(flatbuffers::LoadFile((tests_data_path + "monster_test.fbs").c_str(),
|
||||
@@ -83,7 +83,8 @@ void JsonEnumsTest(const std::string& tests_data_path) {
|
||||
TEST_EQ(std::string::npos != future_json.find("color: 13"), true);
|
||||
}
|
||||
|
||||
void JsonOptionalTest(const std::string& tests_data_path, bool default_scalars) {
|
||||
void JsonOptionalTest(const std::string &tests_data_path,
|
||||
bool default_scalars) {
|
||||
// load FlatBuffer schema (.fbs) and JSON from disk
|
||||
std::string schemafile;
|
||||
std::string jsonfile;
|
||||
@@ -124,7 +125,7 @@ void JsonOptionalTest(const std::string& tests_data_path, bool default_scalars)
|
||||
TEST_EQ_STR(jsongen.c_str(), jsonfile.c_str());
|
||||
}
|
||||
|
||||
void ParseIncorrectMonsterJsonTest(const std::string& tests_data_path) {
|
||||
void ParseIncorrectMonsterJsonTest(const std::string &tests_data_path) {
|
||||
std::string schemafile;
|
||||
TEST_EQ(flatbuffers::LoadFile((tests_data_path + "monster_test.bfbs").c_str(),
|
||||
true, &schemafile),
|
||||
@@ -179,7 +180,7 @@ table JsonUnionStructTest { union_with_struct: UnionWithStruct; }
|
||||
root_type JsonUnionStructTest;
|
||||
)";
|
||||
// source text to parse and expected result of generation text back
|
||||
auto json_source =R"({
|
||||
auto json_source = R"({
|
||||
union_with_struct_type: "MyStruct",
|
||||
union_with_struct: {
|
||||
field: 12345
|
||||
|
||||
@@ -38,7 +38,6 @@ void FixedSizedScalarKeyInStructTest() {
|
||||
bars.push_back(Bar(flatbuffers::make_span(test_float_array4), 1));
|
||||
auto bar_vec = fbb.CreateVectorOfSortedStructs(&bars);
|
||||
|
||||
|
||||
auto t = CreateFooTable(fbb, 1, 2, test_string, baz_vec, bar_vec);
|
||||
|
||||
fbb.Finish(t);
|
||||
@@ -51,15 +50,11 @@ void FixedSizedScalarKeyInStructTest() {
|
||||
TEST_EQ(sorted_baz_vec->Get(3)->b(), 4);
|
||||
|
||||
uint8_t test_array[4];
|
||||
auto* key_array = &flatbuffers::CastToArray(test_array);
|
||||
auto *key_array = &flatbuffers::CastToArray(test_array);
|
||||
key_array->CopyFromSpan(flatbuffers::make_span(test_array1));
|
||||
|
||||
|
||||
TEST_NOTNULL(
|
||||
sorted_baz_vec->LookupByKey(key_array));
|
||||
TEST_EQ(
|
||||
sorted_baz_vec->LookupByKey(key_array)->b(),
|
||||
4);
|
||||
TEST_NOTNULL(sorted_baz_vec->LookupByKey(key_array));
|
||||
TEST_EQ(sorted_baz_vec->LookupByKey(key_array)->b(), 4);
|
||||
uint8_t array_int[4] = { 7, 2, 3, 0 };
|
||||
key_array->CopyFromSpan(flatbuffers::make_span(array_int));
|
||||
TEST_EQ(sorted_baz_vec->LookupByKey(key_array),
|
||||
@@ -70,7 +65,7 @@ void FixedSizedScalarKeyInStructTest() {
|
||||
TEST_EQ(sorted_bar_vec->Get(3)->b(), 4);
|
||||
|
||||
float test_float_array[3];
|
||||
auto* key_float_array = &flatbuffers::CastToArray(test_float_array);
|
||||
auto *key_float_array = &flatbuffers::CastToArray(test_float_array);
|
||||
key_float_array->CopyFromSpan(flatbuffers::make_span(test_float_array1));
|
||||
TEST_NOTNULL(sorted_bar_vec->LookupByKey(key_float_array));
|
||||
TEST_EQ(sorted_bar_vec->LookupByKey(key_float_array)->b(), 3);
|
||||
@@ -105,7 +100,6 @@ void StructKeyInStructTest() {
|
||||
auto orc = foo_builder.Finish();
|
||||
fbb.Finish(orc);
|
||||
|
||||
|
||||
uint8_t *buf = fbb.GetBufferPointer();
|
||||
auto foo_table = GetFooTable(buf);
|
||||
|
||||
@@ -153,9 +147,14 @@ void NestedStructKeyInStructTest() {
|
||||
TEST_EQ(sorted_fruit_vec->Get(0)->b(), 3);
|
||||
TEST_EQ(sorted_fruit_vec->Get(1)->b(), 1);
|
||||
TEST_EQ(sorted_fruit_vec->Get(2)->b(), 2);
|
||||
TEST_EQ(sorted_fruit_vec->LookupByKey(Apple(2, Color(flatbuffers::make_span(test_float_array2), 1)))->b(), 1);
|
||||
TEST_EQ(sorted_fruit_vec->LookupByKey(Apple(1, Color(flatbuffers::make_span(test_float_array2), 1))), static_cast<const Fruit *>(nullptr));
|
||||
|
||||
TEST_EQ(sorted_fruit_vec
|
||||
->LookupByKey(
|
||||
Apple(2, Color(flatbuffers::make_span(test_float_array2), 1)))
|
||||
->b(),
|
||||
1);
|
||||
TEST_EQ(sorted_fruit_vec->LookupByKey(
|
||||
Apple(1, Color(flatbuffers::make_span(test_float_array2), 1))),
|
||||
static_cast<const Fruit *>(nullptr));
|
||||
}
|
||||
|
||||
void FixedSizedStructArrayKeyInStructTest() {
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#include "optional_scalars_test.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "flatbuffers/idl.h"
|
||||
#include "optional_scalars_generated.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
namespace flatbuffers{
|
||||
namespace tests{
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace tests {
|
||||
|
||||
void OptionalScalarsTest() {
|
||||
// Simple schemas and a "has optional scalar" sentinal.
|
||||
@@ -97,5 +98,5 @@ void OptionalScalarsTest() {
|
||||
TEST_ASSERT(opts->maybe_i32() == flatbuffers::Optional<int64_t>(-1));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace tests
|
||||
} // namespace flatbuffers
|
||||
|
||||
@@ -31,8 +31,9 @@ void RunTest(const flatbuffers::IDLOptions &opts, const std::string &proto_path,
|
||||
TEST_EQ(import_parser.Parse(import_proto_file.c_str(), include_directories),
|
||||
true);
|
||||
std::string import_fbs;
|
||||
TEST_EQ(fbs_generator->GenerateCodeString(import_parser, "test", import_fbs),
|
||||
CodeGenerator::Status::OK);
|
||||
TEST_EQ(
|
||||
fbs_generator->GenerateCodeString(import_parser, "test", import_fbs),
|
||||
CodeGenerator::Status::OK);
|
||||
// auto import_fbs = flatbuffers::GenerateFBS(import_parser, "test", true);
|
||||
// Since `imported.fbs` isn't in the filesystem AbsolutePath can't figure it
|
||||
// out by itself. We manually construct it so Parser works.
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
#include "reflection_test.h"
|
||||
|
||||
#include "arrays_test_generated.h"
|
||||
#include "flatbuffers/minireflect.h"
|
||||
#include "flatbuffers/reflection.h"
|
||||
#include "flatbuffers/reflection_generated.h"
|
||||
#include "flatbuffers/verifier.h"
|
||||
#include "test_assert.h"
|
||||
#include "monster_test.h"
|
||||
#include "monster_test_generated.h"
|
||||
#include "test_assert.h"
|
||||
|
||||
namespace flatbuffers {
|
||||
namespace tests {
|
||||
|
||||
using namespace MyGame::Example;
|
||||
|
||||
void ReflectionTest(const std::string& tests_data_path, uint8_t *flatbuf, size_t length) {
|
||||
void ReflectionTest(const std::string &tests_data_path, uint8_t *flatbuf,
|
||||
size_t length) {
|
||||
// Load a binary schema.
|
||||
std::string bfbsfile;
|
||||
TEST_EQ(flatbuffers::LoadFile((tests_data_path + "monster_test.bfbs").c_str(),
|
||||
|
||||
@@ -15,8 +15,7 @@ class TestHeapBuilder : public FlatBufferBuilder {
|
||||
TestHeapBuilder &operator=(const TestHeapBuilder &);
|
||||
|
||||
public:
|
||||
TestHeapBuilder()
|
||||
: FlatBufferBuilder(2048, new OwnedAllocator(), true) {}
|
||||
TestHeapBuilder() : FlatBufferBuilder(2048, new OwnedAllocator(), true) {}
|
||||
|
||||
TestHeapBuilder(TestHeapBuilder &&other)
|
||||
: FlatBufferBuilder(std::move(other)) {}
|
||||
@@ -144,7 +143,7 @@ void FlatBufferBuilderTest() {
|
||||
}
|
||||
|
||||
// forward-declared in test_builder.h
|
||||
void CheckTestGeneratedIsValid(const MyGame::Example::Color&);
|
||||
void CheckTestGeneratedIsValid(const MyGame::Example::Color &);
|
||||
|
||||
// Link-time check using pointer type.
|
||||
void CheckTestGeneratedIsValid(const MyGame::Example::Color &) {}
|
||||
|
||||
Reference in New Issue
Block a user