[libcxx] r273371 - Cleanup [list.modifiers] tests.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 21 20:46:32 PDT 2016
Author: ericwf
Date: Tue Jun 21 22:46:32 2016
New Revision: 273371
URL: http://llvm.org/viewvc/llvm-project?rev=273371&view=rev
Log:
Cleanup [list.modifiers] tests.
Added:
libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/
libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp
libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp
Removed:
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp
Modified:
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
libcxx/trunk/test/support/count_new.hpp
Added: libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp?rev=273371&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp Tue Jun 21 22:46:32 2016
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator position) with end()
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+}
Added: libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp?rev=273371&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp Tue Jun 21 22:46:32 2016
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+}
Added: libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp?rev=273371&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp Tue Jun 21 22:46:32 2016
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+}
+
Added: libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp?rev=273371&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp Tue Jun 21 22:46:32 2016
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+}
Added: libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp?rev=273371&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp Tue Jun 21 22:46:32 2016
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+}
Added: libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp?rev=273371&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp Tue Jun 21 22:46:32 2016
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+}
Added: libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.pass.cpp?rev=273371&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.pass.cpp Tue Jun 21 22:46:32 2016
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <InputIterator Iter>
+// iterator insert(const_iterator position, Iter first, Iter last);
+
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+#include "test_iterators.h"
+
+int main()
+{
+ {
+ std::list<int> v(100);
+ std::list<int> v2(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::list<int>::iterator i = v.insert(next(v2.cbegin(), 10),
+ input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(false);
+ }
+}
Added: libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp?rev=273371&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp Tue Jun 21 22:46:32 2016
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+ std::list<int> c1(100);
+ std::list<int> c2;
+ std::list<int>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1);
+ assert(false);
+}
Added: libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp?rev=273371&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp Tue Jun 21 22:46:32 2016
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#define _LIBCPP_DEBUG 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+
+int main()
+{
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ int i = 4;
+ v1.insert(v2.begin(), i);
+ assert(false);
+}
Removed: libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp?rev=273370&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp (removed)
@@ -1,51 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <list>
-
-// Call erase(const_iterator position) with end()
-
-#if _LIBCPP_DEBUG >= 1
-
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-
-#include <list>
-#include <cassert>
-#include <cstdlib>
-#include <exception>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- int a1[] = {1, 2, 3};
- std::list<int> l1(a1, a1+3);
- std::list<int>::const_iterator i = l1.end();
- l1.erase(i);
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::list<int, min_allocator<int>> l1(a1, a1+3);
- std::list<int, min_allocator<int>>::const_iterator i = l1.end();
- l1.erase(i);
- assert(false);
- }
-#endif
-}
-
-#else
-
-int main()
-{
-}
-
-#endif
Removed: libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp?rev=273370&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp (removed)
@@ -1,53 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <list>
-
-// Call erase(const_iterator position) with iterator from another container
-
-#if _LIBCPP_DEBUG >= 1
-
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-
-#include <list>
-#include <cassert>
-#include <cstdlib>
-#include <exception>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- int a1[] = {1, 2, 3};
- std::list<int> l1(a1, a1+3);
- std::list<int> l2(a1, a1+3);
- std::list<int>::const_iterator i = l2.begin();
- l1.erase(i);
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::list<int, min_allocator<int>> l1(a1, a1+3);
- std::list<int, min_allocator<int>> l2(a1, a1+3);
- std::list<int, min_allocator<int>>::const_iterator i = l2.begin();
- l1.erase(i);
- assert(false);
- }
-#endif
-}
-
-#else
-
-int main()
-{
-}
-
-#endif
Removed: libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp?rev=273370&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp (removed)
@@ -1,51 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <list>
-
-// Call erase(const_iterator first, const_iterator last); with first iterator from another container
-
-#if _LIBCPP_DEBUG >= 1
-
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-
-#include <list>
-#include <cassert>
-#include <exception>
-#include <cstdlib>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- int a1[] = {1, 2, 3};
- std::list<int> l1(a1, a1+3);
- std::list<int> l2(a1, a1+3);
- std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::list<int, min_allocator<int>> l1(a1, a1+3);
- std::list<int, min_allocator<int>> l2(a1, a1+3);
- std::list<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
- assert(false);
- }
-#endif
-}
-
-#else
-
-int main()
-{
-}
-
-#endif
Removed: libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp?rev=273370&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp (removed)
@@ -1,51 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <list>
-
-// Call erase(const_iterator first, const_iterator last); with second iterator from another container
-
-#if _LIBCPP_DEBUG >= 1
-
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-
-#include <list>
-#include <cassert>
-#include <exception>
-#include <cstdlib>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- int a1[] = {1, 2, 3};
- std::list<int> l1(a1, a1+3);
- std::list<int> l2(a1, a1+3);
- std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::list<int, min_allocator<int>> l1(a1, a1+3);
- std::list<int, min_allocator<int>> l2(a1, a1+3);
- std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
- assert(false);
- }
-#endif
-}
-
-#else
-
-int main()
-{
-}
-
-#endif
Removed: libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp?rev=273370&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp (removed)
@@ -1,51 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <list>
-
-// Call erase(const_iterator first, const_iterator last); with both iterators from another container
-
-#if _LIBCPP_DEBUG >= 1
-
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-
-#include <list>
-#include <cassert>
-#include <exception>
-#include <cstdlib>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- int a1[] = {1, 2, 3};
- std::list<int> l1(a1, a1+3);
- std::list<int> l2(a1, a1+3);
- std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::list<int, min_allocator<int>> l1(a1, a1+3);
- std::list<int, min_allocator<int>> l2(a1, a1+3);
- std::list<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
- assert(false);
- }
-#endif
-}
-
-#else
-
-int main()
-{
-}
-
-#endif
Removed: libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp?rev=273370&view=auto
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp (removed)
@@ -1,49 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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.
-//
-//===----------------------------------------------------------------------===//
-
-// <list>
-
-// Call erase(const_iterator first, const_iterator last); with a bad range
-
-#if _LIBCPP_DEBUG >= 1
-
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-
-#include <list>
-#include <cassert>
-#include <exception>
-#include <cstdlib>
-
-#include "min_allocator.h"
-
-int main()
-{
- {
- int a1[] = {1, 2, 3};
- std::list<int> l1(a1, a1+3);
- std::list<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
- assert(false);
- }
-#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::list<int, min_allocator<int>> l1(a1, a1+3);
- std::list<int, min_allocator<int>>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
- assert(false);
- }
-#endif
-}
-
-#else
-
-int main()
-{
-}
-
-#endif
Modified: libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp?rev=273371&r1=273370&r2=273371&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp Tue Jun 21 22:46:32 2016
@@ -7,48 +7,25 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// <list>
// template <InputIterator Iter>
// iterator insert(const_iterator position, Iter first, Iter last);
-// UNSUPPORTED: sanitizer-new-delete
-
-#if _LIBCPP_DEBUG >= 1
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-#endif
-
#include <list>
#include <cstdlib>
#include <cassert>
+
+#include "test_macros.h"
#include "test_iterators.h"
#include "min_allocator.h"
+#include "count_new.hpp"
-int throw_next = 0xFFFF;
-int count = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- if (throw_next == 0)
- throw std::bad_alloc();
- --throw_next;
- ++count;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --count;
- std::free(p);
-}
-
-int main()
-{
- {
+template <class List>
+void test() {
int a1[] = {1, 2, 3};
- std::list<int> l1;
- std::list<int>::iterator i = l1.insert(l1.begin(), a1, a1+3);
+ List l1;
+ typename List::iterator i = l1.insert(l1.begin(), a1, a1+3);
assert(i == l1.begin());
assert(l1.size() == 3);
assert(distance(l1.begin(), l1.end()) == 3);
@@ -75,8 +52,10 @@ int main()
assert(*i == 6);
++i;
assert(*i == 3);
- throw_next = 2;
- int save_count = count;
+
+#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(DISABLE_NEW_COUNT)
+ globalMemCounter.throw_after = 2;
+ int save_count = globalMemCounter.outstanding_new;
try
{
i = l1.insert(i, a2, a2+3);
@@ -85,7 +64,7 @@ int main()
catch (...)
{
}
- assert(save_count == count);
+ assert(globalMemCounter.checkOutstandingNewEq(save_count));
assert(l1.size() == 6);
assert(distance(l1.begin(), l1.end()) == 6);
i = l1.begin();
@@ -100,87 +79,13 @@ int main()
assert(*i == 6);
++i;
assert(*i == 3);
- }
- throw_next = 0xFFFF;
-#if _LIBCPP_DEBUG >= 1
- {
- std::list<int> v(100);
- std::list<int> v2(100);
- int a[] = {1, 2, 3, 4, 5};
- const int N = sizeof(a)/sizeof(a[0]);
- std::list<int>::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator<const int*>(a),
- input_iterator<const int*>(a+N));
- assert(false);
- }
#endif
+}
+
+int main()
+{
+ test<std::list<int> >();
#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- std::list<int, min_allocator<int>> l1;
- std::list<int, min_allocator<int>>::iterator i = l1.insert(l1.begin(), a1, a1+3);
- assert(i == l1.begin());
- assert(l1.size() == 3);
- assert(distance(l1.begin(), l1.end()) == 3);
- i = l1.begin();
- assert(*i == 1);
- ++i;
- assert(*i == 2);
- ++i;
- assert(*i == 3);
- int a2[] = {4, 5, 6};
- i = l1.insert(i, a2, a2+3);
- assert(*i == 4);
- assert(l1.size() == 6);
- assert(distance(l1.begin(), l1.end()) == 6);
- i = l1.begin();
- assert(*i == 1);
- ++i;
- assert(*i == 2);
- ++i;
- assert(*i == 4);
- ++i;
- assert(*i == 5);
- ++i;
- assert(*i == 6);
- ++i;
- assert(*i == 3);
- throw_next = 2;
- int save_count = count;
- try
- {
- i = l1.insert(i, a2, a2+3);
- assert(false);
- }
- catch (...)
- {
- }
- assert(save_count == count);
- assert(l1.size() == 6);
- assert(distance(l1.begin(), l1.end()) == 6);
- i = l1.begin();
- assert(*i == 1);
- ++i;
- assert(*i == 2);
- ++i;
- assert(*i == 4);
- ++i;
- assert(*i == 5);
- ++i;
- assert(*i == 6);
- ++i;
- assert(*i == 3);
- }
-#if _LIBCPP_DEBUG >= 1
- {
- throw_next = 0xFFFF;
- std::list<int, min_allocator<int>> v(100);
- std::list<int, min_allocator<int>> v2(100);
- int a[] = {1, 2, 3, 4, 5};
- const int N = sizeof(a)/sizeof(a[0]);
- std::list<int, min_allocator<int>>::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator<const int*>(a),
- input_iterator<const int*>(a+N));
- assert(false);
- }
-#endif
+ test<std::list<int, min_allocator<int>>>();
#endif
}
Modified: libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp?rev=273371&r1=273370&r2=273371&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp Tue Jun 21 22:46:32 2016
@@ -14,45 +14,23 @@
// UNSUPPORTED: sanitizer-new-delete
-#if _LIBCPP_DEBUG >= 1
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-#endif
-
#include <list>
#include <cstdlib>
#include <cassert>
#include "min_allocator.h"
+#include "count_new.hpp"
-int throw_next = 0xFFFF;
-int count = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- if (throw_next == 0)
- throw std::bad_alloc();
- --throw_next;
- ++count;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --count;
- std::free(p);
-}
-
-int main()
-{
- {
+template <class List>
+void test() {
int a1[] = {1, 2, 3};
int a2[] = {1, 4, 4, 4, 4, 4, 2, 3};
- std::list<int> l1(a1, a1+3);
- std::list<int>::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
+ List l1(a1, a1+3);
+ typename List::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
assert(i == next(l1.begin()));
- assert(l1 == std::list<int>(a2, a2+8));
- throw_next = 4;
- int save_count = count;
+ assert(l1 == List(a2, a2+8));
+ globalMemCounter.throw_after = 4;
+ int save_count = globalMemCounter.outstanding_new;
try
{
i = l1.insert(i, 5, 5);
@@ -61,47 +39,14 @@ int main()
catch (...)
{
}
- throw_next = 0xFFFF;
- assert(save_count == count);
- assert(l1 == std::list<int>(a2, a2+8));
- }
-#if _LIBCPP_DEBUG >= 1
- {
- std::list<int> c1(100);
- std::list<int> c2;
- std::list<int>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1);
- assert(false);
- }
-#endif
+ assert(globalMemCounter.checkOutstandingNewEq(save_count));
+ assert(l1 == List(a2, a2+8));
+}
+
+int main()
+{
+ test<std::list<int> >();
#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- int a2[] = {1, 4, 4, 4, 4, 4, 2, 3};
- std::list<int, min_allocator<int>> l1(a1, a1+3);
- std::list<int, min_allocator<int>>::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
- assert(i == next(l1.begin()));
- assert((l1 == std::list<int, min_allocator<int>>(a2, a2+8)));
- throw_next = 4;
- int save_count = count;
- try
- {
- i = l1.insert(i, 5, 5);
- assert(false);
- }
- catch (...)
- {
- }
- throw_next = 0xFFFF;
- assert(save_count == count);
- assert((l1 == std::list<int, min_allocator<int>>(a2, a2+8)));
- }
-#if _LIBCPP_DEBUG >= 1
- {
- std::list<int, min_allocator<int>> c1(100);
- std::list<int, min_allocator<int>> c2;
- std::list<int, min_allocator<int>>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1);
- assert(false);
- }
-#endif
+ test<std::list<int, min_allocator<int>>>();
#endif
}
Modified: libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp?rev=273371&r1=273370&r2=273371&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp Tue Jun 21 22:46:32 2016
@@ -7,54 +7,33 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// <list>
// iterator insert(const_iterator position, const value_type& x);
-// UNSUPPORTED: sanitizer-new-delete
-
-#if _LIBCPP_DEBUG >= 1
-#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
-#endif
-
#include <list>
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
#include "min_allocator.h"
+#include "count_new.hpp"
-int throw_next = 0xFFFF;
-int count = 0;
-
-void* operator new(std::size_t s) throw(std::bad_alloc)
-{
- if (throw_next == 0)
- throw std::bad_alloc();
- --throw_next;
- ++count;
- return std::malloc(s);
-}
-
-void operator delete(void* p) throw()
-{
- --count;
- std::free(p);
-}
-
-int main()
+template <class List>
+void test()
{
- {
int a1[] = {1, 2, 3};
int a2[] = {1, 4, 2, 3};
- std::list<int> l1(a1, a1+3);
- std::list<int>::iterator i = l1.insert(next(l1.cbegin()), 4);
+ List l1(a1, a1+3);
+ typename List::iterator i = l1.insert(next(l1.cbegin()), 4);
assert(i == next(l1.begin()));
assert(l1.size() == 4);
assert(distance(l1.begin(), l1.end()) == 4);
- assert(l1 == std::list<int>(a2, a2+4));
- throw_next = 0;
- int save_count = count;
+ assert(l1 == List(a2, a2+4));
+
+#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(DISABLE_NEW_COUNT)
+ globalMemCounter.throw_after = 0;
+ int save_count = globalMemCounter.outstanding_new;
try
{
i = l1.insert(i, 5);
@@ -63,51 +42,15 @@ int main()
catch (...)
{
}
- throw_next = 0xFFFF;
- assert(save_count == count);
- assert(l1 == std::list<int>(a2, a2+4));
- }
-#if _LIBCPP_DEBUG >= 1
- {
- std::list<int> v1(3);
- std::list<int> v2(3);
- int i = 4;
- v1.insert(v2.begin(), i);
- assert(false);
- }
+ assert(globalMemCounter.checkOutstandingNewEq(save_count));
+ assert(l1 == List(a2, a2+4));
#endif
+}
+
+int main()
+{
+ test<std::list<int> >();
#if TEST_STD_VER >= 11
- {
- int a1[] = {1, 2, 3};
- int a2[] = {1, 4, 2, 3};
- std::list<int, min_allocator<int>> l1(a1, a1+3);
- std::list<int, min_allocator<int>>::iterator i = l1.insert(next(l1.cbegin()), 4);
- assert(i == next(l1.begin()));
- assert(l1.size() == 4);
- assert(distance(l1.begin(), l1.end()) == 4);
- assert((l1 == std::list<int, min_allocator<int>>(a2, a2+4)));
- throw_next = 0;
- int save_count = count;
- try
- {
- i = l1.insert(i, 5);
- assert(false);
- }
- catch (...)
- {
- }
- throw_next = 0xFFFF;
- assert(save_count == count);
- assert((l1 == std::list<int, min_allocator<int>>(a2, a2+4)));
- }
-#if _LIBCPP_DEBUG >= 1
- {
- std::list<int, min_allocator<int>> v1(3);
- std::list<int, min_allocator<int>> v2(3);
- int i = 4;
- v1.insert(v2.begin(), i);
- assert(false);
- }
-#endif
+ test<std::list<int, min_allocator<int>>>();
#endif
}
Modified: libcxx/trunk/test/support/count_new.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/count_new.hpp?rev=273371&r1=273370&r2=273371&view=diff
==============================================================================
--- libcxx/trunk/test/support/count_new.hpp (original)
+++ libcxx/trunk/test/support/count_new.hpp Tue Jun 21 22:46:32 2016
@@ -22,6 +22,17 @@
#define DISABLE_NEW_COUNT
#endif
+namespace detail
+{
+ inline void throw_bad_alloc_helper() {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ throw std::bad_alloc();
+#else
+ std::abort();
+#endif
+ }
+}
+
class MemCounter
{
public:
@@ -41,6 +52,11 @@ public:
// code doesn't perform any allocations.
bool disable_allocations;
+ // number of allocations to throw after. Default (unsigned)-1. If
+ // throw_after has the default value it will never be decremented.
+ static const unsigned never_throw_value = static_cast<unsigned>(-1);
+ unsigned throw_after;
+
int outstanding_new;
int new_called;
int delete_called;
@@ -56,6 +72,12 @@ public:
{
assert(disable_allocations == false);
assert(s);
+ if (throw_after == 0) {
+ throw_after = never_throw_value;
+ detail::throw_bad_alloc_helper();
+ } else if (throw_after != never_throw_value) {
+ --throw_after;
+ }
++new_called;
++outstanding_new;
last_new_size = s;
@@ -72,6 +94,12 @@ public:
{
assert(disable_allocations == false);
assert(s);
+ if (throw_after == 0) {
+ throw_after = never_throw_value;
+ detail::throw_bad_alloc_helper();
+ } else {
+ // don't decrement throw_after here. newCalled will end up doing that.
+ }
++outstanding_array_new;
++new_array_called;
last_new_array_size = s;
@@ -94,9 +122,11 @@ public:
disable_allocations = false;
}
+
void reset()
{
disable_allocations = false;
+ throw_after = never_throw_value;
outstanding_new = 0;
new_called = 0;
@@ -208,7 +238,10 @@ MemCounter globalMemCounter((MemCounter:
void* operator new(std::size_t s) throw(std::bad_alloc)
{
globalMemCounter.newCalled(s);
- return std::malloc(s);
+ void* ret = std::malloc(s);
+ if (ret == nullptr)
+ detail::throw_bad_alloc_helper();
+ return ret;
}
void operator delete(void* p) throw()
More information about the cfe-commits
mailing list