!std::is_trivially_copyable<Optional<NonDefaultConstructible>>::value,
"not trivially copyable");
-// Test fixture
-class OptionalTest : public testing::Test {
-};
-
-TEST_F(OptionalTest, NonDefaultConstructibleTest) {
+TEST(OptionalTest, NonDefaultConstructibleTest) {
Optional<NonDefaultConstructible> O;
EXPECT_FALSE(O);
}
-TEST_F(OptionalTest, ResetTest) {
+TEST(OptionalTest, ResetTest) {
NonDefaultConstructible::ResetCounts();
Optional<NonDefaultConstructible> O(NonDefaultConstructible(3));
EXPECT_EQ(1u, NonDefaultConstructible::CopyConstructions);
EXPECT_EQ(1u, NonDefaultConstructible::Destructions);
}
-TEST_F(OptionalTest, InitializationLeakTest) {
+TEST(OptionalTest, InitializationLeakTest) {
NonDefaultConstructible::ResetCounts();
Optional<NonDefaultConstructible>(NonDefaultConstructible(3));
EXPECT_EQ(1u, NonDefaultConstructible::CopyConstructions);
EXPECT_EQ(2u, NonDefaultConstructible::Destructions);
}
-TEST_F(OptionalTest, CopyConstructionTest) {
+TEST(OptionalTest, CopyConstructionTest) {
NonDefaultConstructible::ResetCounts();
{
Optional<NonDefaultConstructible> A(NonDefaultConstructible(3));
EXPECT_EQ(2u, NonDefaultConstructible::Destructions);
}
-TEST_F(OptionalTest, ConstructingCopyAssignmentTest) {
+TEST(OptionalTest, ConstructingCopyAssignmentTest) {
NonDefaultConstructible::ResetCounts();
{
Optional<NonDefaultConstructible> A(NonDefaultConstructible(3));
EXPECT_EQ(2u, NonDefaultConstructible::Destructions);
}
-TEST_F(OptionalTest, CopyingCopyAssignmentTest) {
+TEST(OptionalTest, CopyingCopyAssignmentTest) {
NonDefaultConstructible::ResetCounts();
{
Optional<NonDefaultConstructible> A(NonDefaultConstructible(3));
EXPECT_EQ(2u, NonDefaultConstructible::Destructions);
}
-TEST_F(OptionalTest, DeletingCopyAssignmentTest) {
+TEST(OptionalTest, DeletingCopyAssignmentTest) {
NonDefaultConstructible::ResetCounts();
{
Optional<NonDefaultConstructible> A;
EXPECT_EQ(0u, NonDefaultConstructible::Destructions);
}
-TEST_F(OptionalTest, NullCopyConstructionTest) {
+TEST(OptionalTest, NullCopyConstructionTest) {
NonDefaultConstructible::ResetCounts();
{
Optional<NonDefaultConstructible> A;
EXPECT_EQ(0u, NonDefaultConstructible::Destructions);
}
-TEST_F(OptionalTest, GetValueOr) {
+TEST(OptionalTest, GetValueOr) {
Optional<int> A;
EXPECT_EQ(42, A.getValueOr(42));
static_assert(!std::is_trivially_copyable<Optional<MultiArgConstructor>>::value,
"not trivially copyable");
-TEST_F(OptionalTest, Emplace) {
+TEST(OptionalTest, Emplace) {
MultiArgConstructor::ResetCounts();
Optional<MultiArgConstructor> A;
static_assert(!std::is_trivially_copyable<Optional<MoveOnly>>::value,
"not trivially copyable");
-TEST_F(OptionalTest, MoveOnlyNull) {
+TEST(OptionalTest, MoveOnlyNull) {
MoveOnly::ResetCounts();
Optional<MoveOnly> O;
EXPECT_EQ(0u, MoveOnly::MoveConstructions);
EXPECT_EQ(0u, MoveOnly::Destructions);
}
-TEST_F(OptionalTest, MoveOnlyConstruction) {
+TEST(OptionalTest, MoveOnlyConstruction) {
MoveOnly::ResetCounts();
Optional<MoveOnly> O(MoveOnly(3));
EXPECT_TRUE((bool)O);
EXPECT_EQ(1u, MoveOnly::Destructions);
}
-TEST_F(OptionalTest, MoveOnlyMoveConstruction) {
+TEST(OptionalTest, MoveOnlyMoveConstruction) {
Optional<MoveOnly> A(MoveOnly(3));
MoveOnly::ResetCounts();
Optional<MoveOnly> B(std::move(A));
EXPECT_EQ(0u, MoveOnly::Destructions);
}
-TEST_F(OptionalTest, MoveOnlyAssignment) {
+TEST(OptionalTest, MoveOnlyAssignment) {
MoveOnly::ResetCounts();
Optional<MoveOnly> O;
O = MoveOnly(3);
EXPECT_EQ(1u, MoveOnly::Destructions);
}
-TEST_F(OptionalTest, MoveOnlyInitializingAssignment) {
+TEST(OptionalTest, MoveOnlyInitializingAssignment) {
Optional<MoveOnly> A(MoveOnly(3));
Optional<MoveOnly> B;
MoveOnly::ResetCounts();
EXPECT_EQ(0u, MoveOnly::Destructions);
}
-TEST_F(OptionalTest, MoveOnlyNullingAssignment) {
+TEST(OptionalTest, MoveOnlyNullingAssignment) {
Optional<MoveOnly> A;
Optional<MoveOnly> B(MoveOnly(3));
MoveOnly::ResetCounts();
EXPECT_EQ(1u, MoveOnly::Destructions);
}
-TEST_F(OptionalTest, MoveOnlyAssigningAssignment) {
+TEST(OptionalTest, MoveOnlyAssigningAssignment) {
Optional<MoveOnly> A(MoveOnly(3));
Optional<MoveOnly> B(MoveOnly(4));
MoveOnly::ResetCounts();
static_assert(!std::is_trivially_copyable<Optional<Immovable>>::value,
"not trivially copyable");
-TEST_F(OptionalTest, ImmovableEmplace) {
+TEST(OptionalTest, ImmovableEmplace) {
Optional<Immovable> A;
Immovable::ResetCounts();
A.emplace(4);
#if LLVM_HAS_RVALUE_REFERENCE_THIS
-TEST_F(OptionalTest, MoveGetValueOr) {
+TEST(OptionalTest, MoveGetValueOr) {
Optional<MoveOnly> A;
MoveOnly::ResetCounts();
return IsEqual;
}
-TEST_F(OptionalTest, OperatorEqual) {
+TEST(OptionalTest, OperatorEqual) {
CheckRelation<EqualTo>(NoneEq, NoneEq, true);
CheckRelation<EqualTo>(NoneEq, EqualityRhs, false);
CheckRelation<EqualTo>(EqualityLhs, NoneEq, false);
CheckRelation<EqualTo>(EqualityLhs, EqualityRhs, IsEqual);
}
-TEST_F(OptionalTest, OperatorNotEqual) {
+TEST(OptionalTest, OperatorNotEqual) {
CheckRelation<NotEqualTo>(NoneEq, NoneEq, false);
CheckRelation<NotEqualTo>(NoneEq, EqualityRhs, true);
CheckRelation<NotEqualTo>(EqualityLhs, NoneEq, true);
return IsLess;
}
-TEST_F(OptionalTest, OperatorLess) {
+TEST(OptionalTest, OperatorLess) {
CheckRelation<Less>(NoneIneq, NoneIneq, false);
CheckRelation<Less>(NoneIneq, InequalityRhs, true);
CheckRelation<Less>(InequalityLhs, NoneIneq, false);
CheckRelation<Less>(InequalityLhs, InequalityRhs, IsLess);
}
-TEST_F(OptionalTest, OperatorGreater) {
+TEST(OptionalTest, OperatorGreater) {
CheckRelation<Greater>(NoneIneq, NoneIneq, false);
CheckRelation<Greater>(NoneIneq, InequalityRhs, false);
CheckRelation<Greater>(InequalityLhs, NoneIneq, true);
CheckRelation<Greater>(InequalityRhs, InequalityLhs, IsLess);
}
-TEST_F(OptionalTest, OperatorLessEqual) {
+TEST(OptionalTest, OperatorLessEqual) {
CheckRelation<LessEqual>(NoneIneq, NoneIneq, true);
CheckRelation<LessEqual>(NoneIneq, InequalityRhs, true);
CheckRelation<LessEqual>(InequalityLhs, NoneIneq, false);
CheckRelation<LessEqual>(InequalityRhs, InequalityLhs, !IsLess);
}
-TEST_F(OptionalTest, OperatorGreaterEqual) {
+TEST(OptionalTest, OperatorGreaterEqual) {
CheckRelation<GreaterEqual>(NoneIneq, NoneIneq, true);
CheckRelation<GreaterEqual>(NoneIneq, InequalityRhs, false);
CheckRelation<GreaterEqual>(InequalityLhs, NoneIneq, true);
}
};
-TEST_F(OptionalTest, StreamOperator) {
+TEST(OptionalTest, StreamOperator) {
auto to_string = [](Optional<ComparableAndStreamable> O) {
SmallString<16> S;
raw_svector_ostream OS(S);
static Optional<Comparable> get() { return Comparable(); }
};
-TEST_F(OptionalTest, UseInUnitTests) {
+TEST(OptionalTest, UseInUnitTests) {
// Test that we invoke the streaming operators when pretty-printing values in
// EXPECT macros.
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(llvm::None, ComparableAndStreamable::get()),