Skip to content

Commit 0d146a7

Browse files
committed
refactor triviality tests
1 parent 70cad6c commit 0d146a7

File tree

1 file changed

+74
-45
lines changed

1 file changed

+74
-45
lines changed

tests/beman/inplace_vector/spec.test.cpp

Lines changed: 74 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -988,65 +988,94 @@ TYPED_TEST(ReversibleContainerRequirements, REnd) {
988988
// is_trivially_move_assignable_v<T> is true, then IV has a trivial move
989989
// assignment operator.
990990

991-
template <typename Param> class Overview : public BasicTest<Param> {};
992-
TYPED_TEST_SUITE(Overview, AllTypes);
991+
template <typename Param> class Triviality : public BasicTest<Param> {};
992+
TYPED_TEST_SUITE(Triviality, AllTypes);
993+
994+
TYPED_TEST(Triviality, TrivialDefaultConstructible) {
995+
// (6.1) — If is_trivially_copy_constructible_v<T> is true, then IV has a
996+
// trivial copy constructor
993997

994-
TYPED_TEST(Overview, Section6) {
995998
using T = TestFixture::T;
996999
constexpr auto N = TestFixture::N;
9971000
using IV = TestFixture::IV;
9981001

999-
SCOPED_TRACE("If N is zero, then IV is trivially copyable and empty, and "
1000-
"std::is_trivially_default_constructible_v<IV> is true");
10011002
if constexpr (N == 0) {
10021003
EXPECT_TRUE(std::is_trivially_copyable_v<IV>);
10031004
EXPECT_TRUE(std::is_empty_v<IV>);
10041005
EXPECT_TRUE(std::is_trivially_default_constructible_v<IV>);
10051006
}
1006-
{
1007-
SCOPED_TRACE(
1008-
"(6.1) — If is_trivially_copy_constructible_v<T> is true, then "
1009-
"IV has a trivial copy constructor");
1010-
if constexpr (std::is_trivially_copy_constructible_v<T>) {
1011-
EXPECT_TRUE(std::is_trivially_copy_constructible_v<IV>);
1012-
}
1007+
}
1008+
1009+
TYPED_TEST(Triviality, TrivialCopyConstructible) {
1010+
// (6.1) — If is_trivially_copy_constructible_v<T> is true, then IV has a
1011+
// trivial copy constructor
1012+
1013+
using T = TestFixture::T;
1014+
constexpr auto N = TestFixture::N;
1015+
using IV = TestFixture::IV;
1016+
1017+
if constexpr (std::is_trivially_copy_constructible_v<T>) {
1018+
EXPECT_TRUE(std::is_trivially_copy_constructible_v<IV>);
10131019
}
1014-
{
1015-
SCOPED_TRACE(
1016-
"(6.2) — If is_trivially_move_constructible_v<T> is true, then IV "
1017-
"has a trivial move constructor.");
1018-
if constexpr (std::is_trivially_move_constructible_v<T>) {
1019-
EXPECT_TRUE(std::is_trivially_move_constructible_v<IV>);
1020-
}
1020+
}
1021+
1022+
TYPED_TEST(Triviality, TrivialMoveConstructible) {
1023+
// (6.2) — If is_trivially_move_constructible_v<T> is true, then IV has a
1024+
// trivial move constructor.
1025+
1026+
using T = TestFixture::T;
1027+
constexpr auto N = TestFixture::N;
1028+
using IV = TestFixture::IV;
1029+
1030+
if constexpr (std::is_trivially_move_constructible_v<T>) {
1031+
EXPECT_TRUE(std::is_trivially_move_constructible_v<IV>);
10211032
}
1022-
{
1023-
SCOPED_TRACE("(6.3) — If is_trivially_destructible_v<T> is true, then:\n"
1024-
"(6.3.1) — IV has a trivial destructor.");
1025-
if constexpr (std::is_trivially_destructible_v<T>) {
1026-
EXPECT_TRUE(std::is_trivially_destructible_v<IV>);
1027-
}
1033+
}
1034+
1035+
TYPED_TEST(Triviality, TrivialDestructor) {
1036+
// (6.3) — If is_trivially_destructible_v<T> is true, then:
1037+
// (6.3.1) — IV has a trivial destructor.
1038+
1039+
using T = TestFixture::T;
1040+
constexpr auto N = TestFixture::N;
1041+
using IV = TestFixture::IV;
1042+
1043+
if constexpr (std::is_trivially_destructible_v<T>) {
1044+
EXPECT_TRUE(std::is_trivially_destructible_v<IV>);
10281045
}
1029-
{
1030-
SCOPED_TRACE("(6.3) — If is_trivially_destructible_v<T> is true, then:\n"
1031-
"(6.3.2) — If is_trivially_copy_constructible_v<T> && "
1032-
"is_trivially_copy_assignable_v<T> is true, then IV has a "
1033-
"trivial copy assignment operator.");
1034-
if constexpr (std::is_trivially_destructible_v<T> &&
1035-
std::is_trivially_copy_constructible_v<T> &&
1036-
std::is_trivially_copy_assignable_v<T>) {
1037-
EXPECT_TRUE(std::is_trivially_copy_assignable_v<IV>);
1038-
}
1046+
}
1047+
1048+
TYPED_TEST(Triviality, TrivialCopyAssignment) {
1049+
// (6.3) — If is_trivially_destructible_v<T> is true, then:
1050+
// (6.3.2) — If is_trivially_copy_constructible_v<T> &&
1051+
// is_trivially_copy_assignable_v<T> is true, then IV has a trivial copy
1052+
// assignment operator.
1053+
1054+
using T = TestFixture::T;
1055+
constexpr auto N = TestFixture::N;
1056+
using IV = TestFixture::IV;
1057+
1058+
if constexpr (std::is_trivially_destructible_v<T> &&
1059+
std::is_trivially_copy_constructible_v<T> &&
1060+
std::is_trivially_copy_assignable_v<T>) {
1061+
EXPECT_TRUE(std::is_trivially_copy_assignable_v<IV>);
10391062
}
1040-
{
1041-
SCOPED_TRACE("(6.3) — If is_trivially_destructible_v<T> is true, then:\n"
1042-
"(6.3.3) — If is_trivially_move_constructible_v<T> && "
1043-
"is_trivially_move_assignable_v<T> is true, then IV has a "
1044-
"trivial move assignment operator.");
1045-
if constexpr (std::is_trivially_destructible_v<T> &&
1046-
std::is_trivially_move_constructible_v<T> &&
1047-
std::is_trivially_move_assignable_v<T>) {
1048-
EXPECT_TRUE(std::is_trivially_move_assignable_v<IV>);
1049-
}
1063+
}
1064+
1065+
TYPED_TEST(Triviality, TrivialMoveAssignment) {
1066+
// (6.3) — If is_trivially_destructible_v<T> is true, then:
1067+
// (6.3.3) — If is_trivially_move_constructible_v<T> &&
1068+
// is_trivially_move_assignable_v<T> is true, then IV has a trivial move
1069+
// assignment operator.
1070+
1071+
using T = TestFixture::T;
1072+
constexpr auto N = TestFixture::N;
1073+
using IV = TestFixture::IV;
1074+
1075+
if constexpr (std::is_trivially_destructible_v<T> &&
1076+
std::is_trivially_move_constructible_v<T> &&
1077+
std::is_trivially_move_assignable_v<T>) {
1078+
EXPECT_TRUE(std::is_trivially_move_assignable_v<IV>);
10501079
}
10511080
}
10521081

0 commit comments

Comments
 (0)