summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-02-21 07:58:45 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-02-21 07:58:45 +0000
commit485740205bcaa9c348c1675f81e8d1673b7694aa (patch)
tree7403ee3bc2db3ce98977c010c5c76cd4ec43cf87 /unittests
parentea72255f5b0e8d92d5ae9feb5e92605d123888ca (diff)
downloadllvm-485740205bcaa9c348c1675f81e8d1673b7694aa.tar.gz
llvm-485740205bcaa9c348c1675f81e8d1673b7694aa.tar.bz2
llvm-485740205bcaa9c348c1675f81e8d1673b7694aa.tar.xz
Only include move-related Optional<T> tests when rvalue references are available.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175730 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/OptionalTest.cpp62
1 files changed, 32 insertions, 30 deletions
diff --git a/unittests/ADT/OptionalTest.cpp b/unittests/ADT/OptionalTest.cpp
index 6d37bf4e18..21e38475d3 100644
--- a/unittests/ADT/OptionalTest.cpp
+++ b/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