Skip to content

Commit c300258

Browse files
committed
Added SizedDefault Test
1 parent 634b185 commit c300258

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

tests/beman/inplace_vector/spec.test.cpp

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,8 +1296,39 @@ TYPED_TEST(Constructors, SizedDefault) {
12961296
// Preconditions: T is Cpp17DefaultInsertable into inplace_vector.
12971297
// Effects: Constructs an inplace_vector with n default-inserted elements.
12981298
// Complexity : Linear in n.
1299-
// TODO
1300-
GTEST_SKIP();
1299+
1300+
using IV = TestFixture::IV;
1301+
using T = TestFixture::T;
1302+
1303+
IV zero(0);
1304+
EXPECT_EQ(zero, IV{});
1305+
1306+
EXPECT_THROW(IV(IV::capacity() + 1), beman::bad_alloc);
1307+
1308+
constexpr auto mid_size = std::midpoint(0ul, IV::capacity());
1309+
IV mid(mid_size);
1310+
EXPECT_EQ(mid.size(), mid_size);
1311+
if (std::is_same_v<T, NonTriviallyDefaultConstructible> ||
1312+
std::is_same_v<T, NonTrivial>) {
1313+
1314+
IV mid_correct;
1315+
for (auto i = 0ul; i < mid_size; ++i)
1316+
mid_correct.emplace_back();
1317+
1318+
EXPECT_EQ(mid, mid_correct);
1319+
}
1320+
1321+
IV full(IV::capacity());
1322+
EXPECT_EQ(full.size(), IV::capacity());
1323+
if (std::is_same_v<T, NonTriviallyDefaultConstructible> ||
1324+
std::is_same_v<T, NonTrivial>) {
1325+
1326+
IV full_correct;
1327+
for (auto i = 0ul; i < full.size(); ++i)
1328+
full_correct.emplace_back();
1329+
1330+
EXPECT_EQ(full, full_correct);
1331+
}
13011332
}
13021333

13031334
TYPED_TEST(Constructors, SizedValue) {

0 commit comments

Comments
 (0)