diff options
| author | Eric Fiselier <eric@efcs.ca> | 2016-06-22 03:46:32 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2016-06-22 03:46:32 +0000 |
| commit | 8ff743253407e6535048f5c078ac96fa2e86a959 (patch) | |
| tree | 42f3582c281729503cbdb9ddaaa7c116f393f56a /libcxx/test/std/containers | |
| parent | ee462ca1943f609c78a1e5238a5dc62e20046e3b (diff) | |
| download | bcm5719-llvm-8ff743253407e6535048f5c078ac96fa2e86a959.tar.gz bcm5719-llvm-8ff743253407e6535048f5c078ac96fa2e86a959.zip | |
Cleanup [list.modifiers] tests.
llvm-svn: 273371
Diffstat (limited to 'libcxx/test/std/containers')
9 files changed, 53 insertions, 566 deletions
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp deleted file mode 100644 index b27eb4022d0..00000000000 --- a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp +++ /dev/null @@ -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 diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp deleted file mode 100644 index 3bb1b1b6fd3..00000000000 --- a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp +++ /dev/null @@ -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 diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp deleted file mode 100644 index 46eb23946fc..00000000000 --- a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp +++ /dev/null @@ -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 diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp deleted file mode 100644 index 0c390bbe1fd..00000000000 --- a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp +++ /dev/null @@ -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 diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp deleted file mode 100644 index 4b9a37c766b..00000000000 --- a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp +++ /dev/null @@ -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 diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp deleted file mode 100644 index 0a460723a65..00000000000 --- a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp +++ /dev/null @@ -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 diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp index 3803a2101d9..18460a65743 100644 --- a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp @@ -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 } diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp index 32503b48c24..d85c1f4b998 100644 --- a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp @@ -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 } diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp index 1bbc46b952f..87a033be64e 100644 --- a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp @@ -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 } |

