Skip to content

Commit

Permalink
tests/test.cpp contains a couple of tests that are only executed (goo…
Browse files Browse the repository at this point in the history
…gle#7571)

on a subset of platforms. The test calls are guarded via #ifndef
FLATBUFFERS_NO_FILE_TEST.

Embedders of flatbuffers that rely on -Werror,-Wunused-function
compiler flags (like chromium) complain about the exsitence of these
tests in the anonymous namespace.

This CL guards the test definitions as well (not just the test
calls).

Co-authored-by: Dominic Battre <battre@chromium.org>
Co-authored-by: Derek Bailey <derekbailey@google.com>
  • Loading branch information
3 people authored and bulentv committed Oct 21, 2022
1 parent 04cd037 commit ff8aebb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ void TriviallyCopyableTest() {
// clang-format on
}

// Guard against -Wunused-function on platforms without file tests.
#ifndef FLATBUFFERS_NO_FILE_TESTS
void GenerateTableTextTest(const std::string &tests_data_path) {
std::string schemafile;
std::string jsonfile;
Expand Down Expand Up @@ -377,6 +379,7 @@ void UnionVectorTest(const std::string &tests_data_path) {
true);
TEST_EQ(parser2.Parse("{a_type:Bool,a:{b:true}}"), true);
}
#endif

void EndianSwapTest() {
TEST_EQ(flatbuffers::EndianSwap(static_cast<int16_t>(0x1234)), 0x3412);
Expand Down Expand Up @@ -841,6 +844,8 @@ void NativeTypeTest() {
}
}

// Guard against -Wunused-function on platforms without file tests.
#ifndef FLATBUFFERS_NO_FILE_TESTS
// VS10 does not support typed enums, exclude from tests
#if !defined(_MSC_VER) || _MSC_VER >= 1700
void FixedLengthArrayJsonTest(const std::string &tests_data_path, bool binary) {
Expand Down Expand Up @@ -1031,6 +1036,7 @@ void TestEmbeddedBinarySchema(const std::string &tests_data_path) {
parserOrg.builder_.GetSize()),
0);
}
#endif

void NestedVerifierTest() {
// Create a nested monster.
Expand Down

0 comments on commit ff8aebb

Please sign in to comment.