diff options
author | David Blaikie <dblaikie@gmail.com> | 2013-02-21 07:58:45 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2013-02-21 07:58:45 +0000 |
commit | db2c7412e40ff56b1c7455abed08bc16176c2f73 (patch) | |
tree | 598a7607e349107e7d3299c62faf3c62156b9ff6 /llvm/unittests/ADT/OptionalTest.cpp | |
parent | 1bcb538c3f43666a47279fd744a476a7ebe1f397 (diff) | |
download | llvm-db2c7412e40ff56b1c7455abed08bc16176c2f73.zip llvm-db2c7412e40ff56b1c7455abed08bc16176c2f73.tar.gz llvm-db2c7412e40ff56b1c7455abed08bc16176c2f73.tar.bz2 |
Only include move-related Optional<T> tests when rvalue references are available.
llvm-svn: 175730
Diffstat (limited to 'llvm/unittests/ADT/OptionalTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/OptionalTest.cpp | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/llvm/unittests/ADT/OptionalTest.cpp b/llvm/unittests/ADT/OptionalTest.cpp index 6d37bf4..21e3847 100644 --- a/llvm/unittests/ADT/OptionalTest.cpp +++ b/llvm/unittests/ADT/OptionalTest.cpp @@ -40,36 +40,6 @@ unsigned NonDefaultConstructible::CopyConstructions = 0; unsigned NonDefaultConstructible::Destructions = 0; unsigned NonDefaultConstructible::CopyAssignments = 0; -struct MoveOnly { - static unsigned MoveConstructions; - static unsigned Destructions; - static unsigned MoveAssignments; - int val; - explicit MoveOnly(int val) : val(val) { - } - MoveOnly(MoveOnly&& other) { - val = other.val; - ++MoveConstructions; - } - MoveOnly &operator=(MoveOnly&& other) { - val = other.val; - ++MoveAssignments; - return *this; - } - ~MoveOnly() { - ++Destructions; - } - static void ResetCounts() { - MoveConstructions = 0; - Destructions = 0; - MoveAssignments = 0; - } -}; - -unsigned MoveOnly::MoveConstructions = 0; -unsigned MoveOnly::Destructions = 0; -unsigned MoveOnly::MoveAssignments = 0; - // Test fixture class OptionalTest : public testing::Test { }; @@ -199,6 +169,37 @@ TEST_F(OptionalTest, NullCopyConstructionTest) { EXPECT_EQ(0u, NonDefaultConstructible::Destructions); } +#if LLVM_HAS_RVALUE_REFERENCES +struct MoveOnly { + static unsigned MoveConstructions; + static unsigned Destructions; + static unsigned MoveAssignments; + int val; + explicit MoveOnly(int val) : val(val) { + } + MoveOnly(MoveOnly&& other) { + val = other.val; + ++MoveConstructions; + } + MoveOnly &operator=(MoveOnly&& other) { + val = other.val; + ++MoveAssignments; + return *this; + } + ~MoveOnly() { + ++Destructions; + } + static void ResetCounts() { + MoveConstructions = 0; + Destructions = 0; + MoveAssignments = 0; + } +}; + +unsigned MoveOnly::MoveConstructions = 0; +unsigned MoveOnly::Destructions = 0; +unsigned MoveOnly::MoveAssignments = 0; + TEST_F(OptionalTest, MoveOnlyNull) { MoveOnly::ResetCounts(); Optional<MoveOnly> O; @@ -277,6 +278,7 @@ TEST_F(OptionalTest, MoveOnlyAssigningAssignment) { EXPECT_EQ(1u, MoveOnly::MoveAssignments); EXPECT_EQ(1u, MoveOnly::Destructions); } +#endif } // end anonymous namespace |