[llvm] r218783 - Add an immovable type to test Optional<T>::emplace more rigorously after r218732.
David Blaikie
dblaikie at gmail.com
Wed Oct 1 11:29:44 PDT 2014
Author: dblaikie
Date: Wed Oct 1 13:29:44 2014
New Revision: 218783
URL: http://llvm.org/viewvc/llvm-project?rev=218783&view=rev
Log:
Add an immovable type to test Optional<T>::emplace more rigorously after r218732.
Modified:
llvm/trunk/unittests/ADT/OptionalTest.cpp
Modified: llvm/trunk/unittests/ADT/OptionalTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/OptionalTest.cpp?rev=218783&r1=218782&r2=218783&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/OptionalTest.cpp (original)
+++ llvm/trunk/unittests/ADT/OptionalTest.cpp Wed Oct 1 13:29:44 2014
@@ -324,15 +324,36 @@ TEST_F(OptionalTest, MoveOnlyAssigningAs
EXPECT_EQ(1u, MoveOnly::Destructions);
}
+struct Immovable {
+ static unsigned Constructions;
+ static unsigned Destructions;
+ int val;
+ explicit Immovable(int val) : val(val) {
+ ++Constructions;
+ }
+ ~Immovable() {
+ ++Destructions;
+ }
+ static void ResetCounts() {
+ Constructions = 0;
+ Destructions = 0;
+ }
+private:
+ // This should disable all move/copy operations.
+ Immovable(Immovable&& other) LLVM_DELETED_FUNCTION;
+};
+
+unsigned Immovable::Constructions = 0;
+unsigned Immovable::Destructions = 0;
+
TEST_F(OptionalTest, MoveOnlyEmplace) {
- Optional<MoveOnly> A;
- MoveOnly::ResetCounts();
+ Optional<Immovable> A;
+ Immovable::ResetCounts();
A.emplace(4);
EXPECT_TRUE((bool)A);
EXPECT_EQ(4, A->val);
- EXPECT_EQ(0u, MoveOnly::MoveConstructions);
- EXPECT_EQ(0u, MoveOnly::MoveAssignments);
- EXPECT_EQ(0u, MoveOnly::Destructions);
+ EXPECT_EQ(1u, Immovable::Constructions);
+ EXPECT_EQ(0u, Immovable::Destructions);
}
#if LLVM_HAS_RVALUE_REFERENCE_THIS
More information about the llvm-commits
mailing list