Browse Source

Adjust two tests to account for a nasty change in copying behavior
between C++03 and C++0x and its effect on exceptions, and another two to
not test move construction when rvalue references are not available.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@135445 91177308-0d34-0410-b5e6-96231b3b80d8

Sean Hunt 14 years ago
parent
commit
541cb301a1

+ 2 - 0
test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp

@@ -42,6 +42,7 @@ int A::count = 0;
 
 int main()
 {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     {
         std::shared_ptr<A> pA(new A);
         A* ptrA = pA.get();
@@ -118,4 +119,5 @@ int main()
     }
     assert(B::count == 0);
     assert(A::count == 0);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }

+ 2 - 0
test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp

@@ -42,6 +42,7 @@ int A::count = 0;
 
 int main()
 {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     {
         std::shared_ptr<A> pA(new A);
         A* ptrA = pA.get();
@@ -118,4 +119,5 @@ int main()
     }
     assert(B::count == 0);
     assert(A::count == 0);
+#endif // _LIBCXX_HAS_NO_RVALUE_REFERENCES
 }

+ 8 - 0
test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp

@@ -85,9 +85,17 @@ int main()
     }
     catch (...)
     {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
         assert(A::count == 1);
         assert(B::count == 1);
         assert(ptr.get() == raw_ptr);
+#else
+        // Without rvalue references, ptr got copied into
+        // the shared_ptr destructor and the copy was
+        // destroyed during unwinding.
+        assert(A::count == 0);
+        assert(B::count == 0);
+#endif
     }
     }
     assert(A::count == 0);

+ 6 - 0
test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp

@@ -77,9 +77,15 @@ int main()
     }
     catch (...)
     {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
         assert(A::count == 1);
         assert(B::count == 1);
         assert(ptr.get() == raw_ptr);
+#else
+        assert(A::count == 0);
+        assert(B::count == 0);
+        assert(ptr.get() == 0);
+#endif
     }
     }
     assert(A::count == 0);