From 136d75fa6580ef87d1b7cbc243e617f21149852e Mon Sep 17 00:00:00 2001 From: Derek Bailey Date: Thu, 21 Nov 2019 10:25:31 -0800 Subject: [PATCH] Changed null checks in test. Removed verifier pointer usage (#5634) --- tests/test.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/test.cpp b/tests/test.cpp index 68716c6..515e2c4 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -2319,7 +2319,6 @@ void EvolutionTest() { std::string schemas[NUM_VERSIONS]; std::string jsonfiles[NUM_VERSIONS]; std::vector binaries[NUM_VERSIONS]; - flatbuffers::Verifier *verifiers[NUM_VERSIONS]; flatbuffers::IDLOptions idl_opts; idl_opts.lang_to_generate |= flatbuffers::IDLOptions::kBinary; @@ -2341,26 +2340,25 @@ void EvolutionTest() { auto buf = parser.builder_.GetBufferPointer(); binaries[i].reserve(bufLen); std::copy(buf, buf + bufLen, std::back_inserter(binaries[i])); - - verifiers[i] = new flatbuffers::Verifier(&binaries[i].front(), bufLen); } // Assert that all the verifiers for the different schema versions properly verify any version data. for (int i = 0; i < NUM_VERSIONS; ++i) { - TEST_ASSERT(Evolution::V1::VerifyRootBuffer(*verifiers[i])); - TEST_ASSERT(Evolution::V2::VerifyRootBuffer(*verifiers[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 'j' is new in version 2, so it should be null. - TEST_EQ(root_v1_viewed_from_v2->j(), NULL); + TEST_ASSERT(nullptr == root_v1_viewed_from_v2->j()); // field 'k' is new in version 2 with a default of 56. TEST_EQ(root_v1_viewed_from_v2->k(), 56); // field 'c' of 'TableA' is new in version 2, so it should be null. - TEST_EQ(root_v1_viewed_from_v2->e()->c(), 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_EQ(root_v1_viewed_from_v2->c_as_TableC(), 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. -- 2.7.4