[libcxx] r178033 - More vector debug tests.

Howard Hinnant hhinnant at apple.com
Tue Mar 26 08:45:57 PDT 2013


Author: hhinnant
Date: Tue Mar 26 10:45:56 2013
New Revision: 178033

URL: http://llvm.org/viewvc/llvm-project?rev=178033&view=rev
Log:
More vector debug tests.

Added:
    libcxx/trunk/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp
Modified:
    libcxx/trunk/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
    libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
    libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
    libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
    libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp

Modified: libcxx/trunk/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp?rev=178033&r1=178032&r2=178033&view=diff
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp (original)
+++ libcxx/trunk/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp Tue Mar 26 10:45:56 2013
@@ -11,6 +11,10 @@
 
 // template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
 
+#if _LIBCPP_DEBUG2 >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
 #include <vector>
 #include <cassert>
 #include "../../../stack_allocator.h"
@@ -102,5 +106,13 @@ int main()
         assert(c.back().geti() == 3);
         assert(c.back().getd() == 4.5);
     }
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        std::vector<A> c1;
+        std::vector<A> c2;
+        std::vector<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+        assert(false);
+    }
+#endif
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }

Modified: libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp?rev=178033&r1=178032&r2=178033&view=diff
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp (original)
+++ libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp Tue Mar 26 10:45:56 2013
@@ -12,6 +12,10 @@
 // template <class Iter>
 //   iterator insert(const_iterator position, Iter first, Iter last);
 
+#if _LIBCPP_DEBUG2 >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
 #include <vector>
 #include <cassert>
 #include "../../../stack_allocator.h"
@@ -83,4 +87,15 @@ int main()
         for (; j < 105; ++j)
             assert(v[j] == 0);
     }
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        std::vector<int> v(100);
+        std::vector<int> v2(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
+                                        input_iterator<const int*>(a+N));
+        assert(false);
+    }
+#endif
 }

Modified: libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp?rev=178033&r1=178032&r2=178033&view=diff
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp (original)
+++ libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp Tue Mar 26 10:45:56 2013
@@ -11,6 +11,10 @@
 
 // iterator insert(const_iterator position, value_type&& x);
 
+#if _LIBCPP_DEBUG2 >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
 #include <vector>
 #include <cassert>
 #include "../../../stack_allocator.h"
@@ -43,5 +47,13 @@ int main()
         for (++j; j < 101; ++j)
             assert(v[j] == MoveOnly());
     }
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        std::vector<int> v1(3);
+        std::vector<int> v2(3);
+        v1.insert(v2.begin(), 4);
+        assert(false);
+    }
+#endif
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }

Modified: libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp?rev=178033&r1=178032&r2=178033&view=diff
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp (original)
+++ libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp Tue Mar 26 10:45:56 2013
@@ -11,6 +11,10 @@
 
 // iterator insert(const_iterator position, size_type n, const value_type& x);
 
+#if _LIBCPP_DEBUG2 >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
 #include <vector>
 #include <cassert>
 #include "../../../stack_allocator.h"
@@ -43,4 +47,12 @@ int main()
         for (++j; j < 105; ++j)
             assert(v[j] == 0);
     }
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        std::vector<int> c1(100);
+        std::vector<int> c2;
+        std::vector<int>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
+        assert(false);
+    }
+#endif
 }

Modified: libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp?rev=178033&r1=178032&r2=178033&view=diff
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp (original)
+++ libcxx/trunk/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp Tue Mar 26 10:45:56 2013
@@ -11,6 +11,10 @@
 
 // iterator insert(const_iterator position, const value_type& x);
 
+#if _LIBCPP_DEBUG2 >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
 #include <vector>
 #include <cassert>
 #include "../../../stack_allocator.h"
@@ -41,4 +45,13 @@ int main()
         for (++j; j < 101; ++j)
             assert(v[j] == 0);
     }
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        std::vector<int> v1(3);
+        std::vector<int> v2(3);
+        int i = 4;
+        v1.insert(v2.begin(), i);
+        assert(false);
+    }
+#endif
 }

Added: libcxx/trunk/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp?rev=178033&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp Tue Mar 26 10:45:56 2013
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class T, class Alloc>
+//   void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+
+#if _LIBCPP_DEBUG2 >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG2 >= 1
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        std::vector<int>::iterator i1 = c1.begin();
+        std::vector<int>::iterator i2 = c2.begin();
+        swap(c1, c2);
+        c1.erase(i2);
+        c2.erase(i1);
+        c1.erase(i1);
+        assert(false);
+    }
+#endif
+}





More information about the cfe-commits mailing list