Skip to content

Commit

Permalink
Use TEST_NOTNULL
Browse files Browse the repository at this point in the history
  • Loading branch information
svenk177 committed Jun 14, 2019
1 parent d7fefbc commit 2c80d93
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2687,25 +2687,25 @@ void FixedLengthArrayTest() {
// VS10 does not support typed enums, exclude from tests
#if !defined(_MSC_VER) || _MSC_VER >= 1700
MyGame::Example::NestedStruct nStruct0(MyGame::Example::TestEnum::B);
TEST_ASSERT(nStruct0.mutable_a() != nullptr);
TEST_NOTNULL(nStruct0.mutable_a());
nStruct0.mutable_a()->Mutate(0, 1);
nStruct0.mutable_a()->Mutate(1, 2);
TEST_ASSERT(nStruct0.mutable_c() != nullptr);
TEST_NOTNULL(nStruct0.mutable_c());
nStruct0.mutable_c()->Mutate(0, MyGame::Example::TestEnum::C);
nStruct0.mutable_c()->Mutate(1, MyGame::Example::TestEnum::A);

MyGame::Example::NestedStruct nStruct1(MyGame::Example::TestEnum::C);
TEST_ASSERT(nStruct1.mutable_a() != nullptr);
TEST_NOTNULL(nStruct1.mutable_a());
nStruct1.mutable_a()->Mutate(0, 3);
nStruct1.mutable_a()->Mutate(1, 4);
TEST_ASSERT(nStruct1.mutable_c() != nullptr);
TEST_NOTNULL(nStruct1.mutable_c());
nStruct1.mutable_c()->Mutate(0, MyGame::Example::TestEnum::C);
nStruct1.mutable_c()->Mutate(1, MyGame::Example::TestEnum::A);

MyGame::Example::ArrayStruct aStruct(2, 12);
TEST_ASSERT(aStruct.b() != nullptr);
TEST_ASSERT(aStruct.mutable_b() != nullptr);
TEST_ASSERT(aStruct.mutable_d() != nullptr);
TEST_NOTNULL(aStruct.b());
TEST_NOTNULL(aStruct.mutable_b());
TEST_NOTNULL(aStruct.mutable_d());
for (int i = 0; i < aStruct.b()->size(); i++)
aStruct.mutable_b()->Mutate(i, i + 1);
aStruct.mutable_d()->Mutate(0, nStruct0);
Expand All @@ -2717,35 +2717,34 @@ void FixedLengthArrayTest() {

auto p = MyGame::Example::GetMutableArrayTable(fbb.GetBufferPointer());
auto mArStruct = p->mutable_a();
TEST_ASSERT(mArStruct != nullptr);
TEST_ASSERT(mArStruct->b() != nullptr);
TEST_ASSERT(mArStruct->d() != nullptr);
TEST_ASSERT(mArStruct->mutable_b() != nullptr);
TEST_ASSERT(mArStruct->mutable_d() != nullptr);
TEST_NOTNULL(mArStruct);
TEST_NOTNULL(mArStruct->b());
TEST_NOTNULL(mArStruct->d());
TEST_NOTNULL(mArStruct->mutable_b());
TEST_NOTNULL(mArStruct->mutable_d());
mArStruct->mutable_b()->Mutate(14, -14);
TEST_EQ(mArStruct->a(), 2);
TEST_EQ(mArStruct->b()->size(), 15);
TEST_EQ(mArStruct->b()->Get(aStruct.b()->size() - 1), -14);
TEST_EQ(mArStruct->c(), 12);
TEST_ASSERT(mArStruct->d()->Get(0).a() != nullptr);
TEST_NOTNULL(mArStruct->d()->Get(0).a());
TEST_EQ(mArStruct->d()->Get(0).a()->Get(0), 1);
TEST_EQ(mArStruct->d()->Get(0).a()->Get(1), 2);
TEST_ASSERT(mArStruct->d()->Get(1).a() != nullptr);
TEST_NOTNULL(mArStruct->d()->Get(1).a());
TEST_EQ(mArStruct->d()->Get(1).a()->Get(0), 3);
TEST_EQ(mArStruct->d()->Get(1).a()->Get(1), 4);
TEST_ASSERT(mArStruct->mutable_d()->GetMutablePointer(1) != nullptr);
TEST_ASSERT(mArStruct->mutable_d()->GetMutablePointer(1)->mutable_a() !=
nullptr);
TEST_NOTNULL(mArStruct->mutable_d()->GetMutablePointer(1));
TEST_NOTNULL(mArStruct->mutable_d()->GetMutablePointer(1)->mutable_a());
mArStruct->mutable_d()->GetMutablePointer(1)->mutable_a()->Mutate(1, 5);
TEST_EQ(mArStruct->d()->Get(1).a()->Get(1), 5);
TEST_EQ(mArStruct->d()->Get(0).b() == MyGame::Example::TestEnum::B, true);
TEST_ASSERT(mArStruct->d()->Get(0).c() != nullptr);
TEST_NOTNULL(mArStruct->d()->Get(0).c());
TEST_EQ(mArStruct->d()->Get(0).c()->Get(0) == MyGame::Example::TestEnum::C,
true);
TEST_EQ(mArStruct->d()->Get(0).c()->Get(1) == MyGame::Example::TestEnum::A,
true);
TEST_EQ(mArStruct->d()->Get(1).b() == MyGame::Example::TestEnum::C, true);
TEST_ASSERT(mArStruct->d()->Get(1).c() != nullptr);
TEST_NOTNULL(mArStruct->d()->Get(1).c());
TEST_EQ(mArStruct->d()->Get(1).c()->Get(0) == MyGame::Example::TestEnum::C,
true);
TEST_EQ(mArStruct->d()->Get(1).c()->Get(1) == MyGame::Example::TestEnum::A,
Expand Down

0 comments on commit 2c80d93

Please sign in to comment.