mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-10 04:33:40 +00:00
Add an immovable type to test Optional<T>::emplace more rigorously after r218732.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218783 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
10c4265675
commit
7538babc12
@ -324,15 +324,36 @@ TEST_F(OptionalTest, MoveOnlyAssigningAssignment) {
|
|||||||
EXPECT_EQ(1u, MoveOnly::Destructions);
|
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) {
|
TEST_F(OptionalTest, MoveOnlyEmplace) {
|
||||||
Optional<MoveOnly> A;
|
Optional<Immovable> A;
|
||||||
MoveOnly::ResetCounts();
|
Immovable::ResetCounts();
|
||||||
A.emplace(4);
|
A.emplace(4);
|
||||||
EXPECT_TRUE((bool)A);
|
EXPECT_TRUE((bool)A);
|
||||||
EXPECT_EQ(4, A->val);
|
EXPECT_EQ(4, A->val);
|
||||||
EXPECT_EQ(0u, MoveOnly::MoveConstructions);
|
EXPECT_EQ(1u, Immovable::Constructions);
|
||||||
EXPECT_EQ(0u, MoveOnly::MoveAssignments);
|
EXPECT_EQ(0u, Immovable::Destructions);
|
||||||
EXPECT_EQ(0u, MoveOnly::Destructions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LLVM_HAS_RVALUE_REFERENCE_THIS
|
#if LLVM_HAS_RVALUE_REFERENCE_THIS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user