From 59515e3bc70c6df2a3d2476c03930abfaf0a7b82 Mon Sep 17 00:00:00 2001 From: Auto Differentiation Dev Team <107129969+auto-differentiation-dev@users.noreply.github.com> Date: Mon, 25 Nov 2024 23:56:11 +0000 Subject: [PATCH] Increase test coverage in new containers --- test/ChunkContainer_test.cpp | 13 +++++++++++++ test/OperationsContainer_test.cpp | 14 ++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/test/ChunkContainer_test.cpp b/test/ChunkContainer_test.cpp index 77b13c27..aa1feebb 100644 --- a/test/ChunkContainer_test.cpp +++ b/test/ChunkContainer_test.cpp @@ -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, 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; + } +} \ No newline at end of file diff --git a/test/OperationsContainer_test.cpp b/test/OperationsContainer_test.cpp index 24f5892b..db6b6dae 100644 --- a/test/OperationsContainer_test.cpp +++ b/test/OperationsContainer_test.cpp @@ -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; } @@ -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)); }