Skip to content

Commit

Permalink
Increase test coverage in new containers
Browse files Browse the repository at this point in the history
  • Loading branch information
auto-differentiation-dev committed Nov 25, 2024
1 parent 88b70d3 commit 59515e3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
13 changes: 13 additions & 0 deletions test/ChunkContainer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,16 @@ TEST(ChunkContainer, push_back_no_check)

for (int i = 0; i < 17; ++i) EXPECT_THAT(chk[size_t(i)], Eq(i)) << "at " << i;
}

TEST(ChunkContainer, emplace_back)
{
ChunkContainer<std::pair<int, int>, 8> chk;
for (int i = 0; i < 17; ++i) chk.emplace_back(i, i);

EXPECT_THAT(chk.size(), Eq(17u));

for (int i = 0; i < 17; ++i)
{
EXPECT_THAT(chk[size_t(i)], Pair(i, i)) << "at " << i;
}
}
14 changes: 8 additions & 6 deletions test/OperationsContainer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ TYPED_TEST(OperationsContainerTest, canResizeExtendingSize)
{
auto c = TypeParam();
c.push_back(42.0, 123);
c.resize(8);
c.resize(9);

EXPECT_THAT(c.size(), Eq(8));
EXPECT_THAT(c[0], Pair(42.0, 123));
for (unsigned i = 1; i < 8; ++i)
for (unsigned i = 1; i < 9; ++i)
{
EXPECT_THAT(c[i], Pair(0.0, 0)) << "for i=" << i;
}
Expand Down Expand Up @@ -198,10 +198,12 @@ TYPED_TEST(OperationsContainerTest2, callsDestructOnDisposal)
TestStruct::items = 0;
{
auto c = TypeParam();
c.push_back(TestStruct(), 1);
c.push_back(TestStruct(), 2);
EXPECT_THAT(c[1], Pair(_, 2));
EXPECT_THAT(TestStruct::items, Eq(2));
for (int i = 0; i < 13; ++i)
{
c.push_back(TestStruct(), i);
}
EXPECT_THAT(c[1], Pair(_, 1));
EXPECT_THAT(TestStruct::items, Eq(13));
}
EXPECT_THAT(TestStruct::items, Eq(0));
}
Expand Down

0 comments on commit 59515e3

Please sign in to comment.