[libc++] Overhaul all tests for assertions and debug mode

Prior to this patch, there was no distinction between tests that check
basic assertions and tests that check full-fledged iterator debugging
assertions. Both were disabled when support for the debug mode is not
provided in the dylib, which is stronger than it needs to be.

Furthermore, all of the tests using "debug_macros.h" that contain more
than one assertion in them were broken -- any code after the first
assertion would never be executed.

This patch refactors all of our assertion-related tests to:
1. Be enabled whenever they can, i.e. basic assertions tests are run
   even when the debug mode is disabled.
2. Use the superior `check_assertion.h` (previously `debug_mode_helper.h`)
   instead of `debug_macros.h`, which allows multiple assertions in the
   same program.
3. Coalesce some tests into the same file to make them more readable.
4. Use consistent naming for test files -- no more db{1,2,3,...,10} tests.

This is a large but mostly mechanical patch.

Differential Revision: https://reviews.llvm.org/D121462
This commit is contained in:
Louis Dionne 2022-03-07 16:58:16 -05:00
parent 6ac3d8ef9c
commit f6fd1c1438
243 changed files with 2393 additions and 4422 deletions

View File

@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template <class _Compare> struct __debug_less
// Make sure __debug_less asserts when the comparator is not consistent.
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <algorithm>
#include <iterator>
#include "check_assertion.h"
template <int ID>
struct MyType {
int value;
explicit MyType(int xvalue = 0) : value(xvalue) {}
};
template <int ID1, int ID2>
bool operator<(MyType<ID1> const& LHS, MyType<ID2> const& RHS) {
return LHS.value < RHS.value;
}
template <class ValueType>
struct BadComparator {
bool operator()(ValueType const&, ValueType const&) const {
return true;
}
};
int main(int, char**) {
typedef MyType<0> MT0;
MT0 one(1);
MT0 two(2);
BadComparator<MT0> c;
std::__debug_less<BadComparator<MT0>> d(c);
TEST_LIBCPP_ASSERT_FAILURE(d(one, two), "Comparator does not induce a strict weak ordering");
return 0;
}

View File

@ -12,8 +12,7 @@
// __debug_less checks that a comparator actually provides a strict-weak ordering.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <algorithm>
@ -21,7 +20,7 @@
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
template <int ID>
struct MyType {
@ -51,14 +50,6 @@ struct GoodComparator : public CompareBase {
}
};
template <class ValueType>
struct BadComparator : public CompareBase {
bool operator()(ValueType const&, ValueType const&) const {
++CompareBase::called;
return true;
}
};
template <class T1, class T2>
struct TwoWayHomoComparator : public CompareBase {
bool operator()(T1 const& lhs, T2 const& rhs) const {
@ -138,20 +129,6 @@ void test_passing() {
}
}
void test_failing() {
MT0 one(1);
MT0 two(2);
{
typedef BadComparator<MT0> C;
typedef __debug_less<C> D;
C c;
D d(c);
TEST_LIBCPP_ASSERT_FAILURE(d(one, two), "Comparator does not induce a strict weak ordering");
}
}
template <int>
struct Tag {
explicit Tag(int v) : value(v) {}
@ -271,7 +248,6 @@ constexpr bool test_constexpr() {
int main(int, char**) {
test_passing();
test_failing();
test_upper_and_lower_bound();
test_non_const_arg_cmp();
test_value_iterator();

View File

@ -10,9 +10,7 @@
// Test std::nth_element stability randomization
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <algorithm>

View File

@ -10,9 +10,7 @@
// Test std::partial_sort stability randomization
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <algorithm>

View File

@ -10,9 +10,7 @@
// Test std::sort stability randomization
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <algorithm>

View File

@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
// test that array<T, 0>::back() triggers an assertion
#include <array>
#include "check_assertion.h"
int main(int, char**) {
{
typedef std::array<int, 0> C;
C c = {};
C const& cc = c;
TEST_LIBCPP_ASSERT_FAILURE(c.back(), "cannot call array<T, 0>::back() on a zero-sized array");
TEST_LIBCPP_ASSERT_FAILURE(cc.back(), "cannot call array<T, 0>::back() on a zero-sized array");
}
{
typedef std::array<const int, 0> C;
C c = {{}};
C const& cc = c;
TEST_LIBCPP_ASSERT_FAILURE(c.back(), "cannot call array<T, 0>::back() on a zero-sized array");
TEST_LIBCPP_ASSERT_FAILURE(cc.back(), "cannot call array<T, 0>::back() on a zero-sized array");
}
return 0;
}

View File

@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
// test that array<T, 0>::back() triggers an assertion
#include <array>
#include "check_assertion.h"
int main(int, char**) {
{
typedef std::array<int, 0> C;
C c = {};
C const& cc = c;
TEST_LIBCPP_ASSERT_FAILURE(c.front(), "cannot call array<T, 0>::front() on a zero-sized array");
TEST_LIBCPP_ASSERT_FAILURE(cc.front(), "cannot call array<T, 0>::front() on a zero-sized array");
}
{
typedef std::array<const int, 0> C;
C c = {{}};
C const& cc = c;
TEST_LIBCPP_ASSERT_FAILURE(c.front(), "cannot call array<T, 0>::front() on a zero-sized array");
TEST_LIBCPP_ASSERT_FAILURE(cc.front(), "cannot call array<T, 0>::front() on a zero-sized array");
}
return 0;
}

View File

@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
// test that array<T, 0>::operator[] triggers an assertion
#include <array>
#include "check_assertion.h"
int main(int, char**) {
{
typedef std::array<int, 0> C;
C c = {};
C const& cc = c;
TEST_LIBCPP_ASSERT_FAILURE(c[0], "cannot call array<T, 0>::operator[] on a zero-sized array");
TEST_LIBCPP_ASSERT_FAILURE(c[1], "cannot call array<T, 0>::operator[] on a zero-sized array");
TEST_LIBCPP_ASSERT_FAILURE(cc[0], "cannot call array<T, 0>::operator[] on a zero-sized array");
TEST_LIBCPP_ASSERT_FAILURE(cc[1], "cannot call array<T, 0>::operator[] on a zero-sized array");
}
{
typedef std::array<const int, 0> C;
C c = {{}};
C const& cc = c;
TEST_LIBCPP_ASSERT_FAILURE(c[0], "cannot call array<T, 0>::operator[] on a zero-sized array");
TEST_LIBCPP_ASSERT_FAILURE(c[1], "cannot call array<T, 0>::operator[] on a zero-sized array");
TEST_LIBCPP_ASSERT_FAILURE(cc[0], "cannot call array<T, 0>::operator[] on a zero-sized array");
TEST_LIBCPP_ASSERT_FAILURE(cc[1], "cannot call array<T, 0>::operator[] on a zero-sized array");
}
return 0;
}

View File

@ -1,38 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// UNSUPPORTED: windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: libcxx-no-debug-mode
// test array<T, 0>::front() raises a debug error.
#include <array>
#include "test_macros.h"
#include "debug_mode_helper.h"
int main(int, char**)
{
{
typedef std::array<int, 0> C;
C c = {};
C const& cc = c;
EXPECT_DEATH( c.back() );
EXPECT_DEATH( cc.back() );
}
{
typedef std::array<const int, 0> C;
C c = {{}};
C const& cc = c;
EXPECT_DEATH( c.back() );
EXPECT_DEATH( cc.back() );
}
return 0;
}

View File

@ -1,38 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// UNSUPPORTED: windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: libcxx-no-debug-mode
// test array<T, 0>::front() raises a debug error.
#include <array>
#include "test_macros.h"
#include "debug_mode_helper.h"
int main(int, char**)
{
{
typedef std::array<int, 0> C;
C c = {};
C const& cc = c;
EXPECT_DEATH(c.front());
EXPECT_DEATH(cc.front());
}
{
typedef std::array<const int, 0> C;
C c = {{}};
C const& cc = c;
EXPECT_DEATH(c.front());
EXPECT_DEATH(cc.front());
}
return 0;
}

View File

@ -1,42 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// UNSUPPORTED: windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: libcxx-no-debug-mode
// test array<T, 0>::operator[] raises a debug error.
#include <array>
#include "test_macros.h"
#include "debug_mode_helper.h"
int main(int, char**)
{
{
typedef std::array<int, 0> C;
C c = {};
C const& cc = c;
EXPECT_DEATH( c[0] );
EXPECT_DEATH( c[1] );
EXPECT_DEATH( cc[0] );
EXPECT_DEATH( cc[1] );
}
{
typedef std::array<const int, 0> C;
C c = {{}};
C const& cc = c;
EXPECT_DEATH( c[0] );
EXPECT_DEATH( c[1] );
EXPECT_DEATH( cc[0] );
EXPECT_DEATH( cc[1] );
}
return 0;
}

View File

@ -10,14 +10,12 @@
// pop_back() more than the number of elements in a deque
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <deque>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**) {
std::deque<int> q;

View File

@ -10,17 +10,14 @@
// list(list&& c);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**)
{
int main(int, char**) {
std::list<int> l1;
l1.push_back(1); l1.push_back(2); l1.push_back(3);
std::list<int>::iterator i = l1.begin();

View File

@ -10,17 +10,14 @@
// Call erase(const_iterator position) with end()
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**)
{
int main(int, char**) {
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int>::const_iterator i = l1.end();

View File

@ -10,18 +10,15 @@
// void pop_back();
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <list>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**)
{
int main(int, char**) {
int a[] = {1, 2, 3};
std::list<int> c(a, a+3);
c.pop_back();

View File

@ -10,15 +10,12 @@
// template <class... Args> void emplace(const_iterator p, Args&&... args);
// UNSUPPORTED: c++03
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
struct A {
explicit A(int i, double d) {
@ -27,8 +24,7 @@ struct A {
}
};
int main(int, char**)
{
int main(int, char**) {
std::list<A> c1;
std::list<A> c2;
TEST_LIBCPP_ASSERT_FAILURE(c1.emplace(c2.cbegin(), 2, 3.5),

View File

@ -10,17 +10,14 @@
// Call erase(const_iterator position) with iterator from another container
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**)
{
int main(int, char**) {
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int> l2(a1, a1+3);

View File

@ -0,0 +1,57 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <list>
// Call erase(const_iterator first, const_iterator last); with various invalid iterators
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "check_assertion.h"
int main(int, char**) {
// First iterator from another container
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int> l2(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l2.cbegin(), std::next(l1.cbegin())),
"list::erase(iterator, iterator) called with an iterator not referring to this list");
}
// Second iterator from another container
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int> l2(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin(), std::next(l2.cbegin())),
"list::erase(iterator, iterator) called with an iterator not referring to this list");
}
// Both iterators from another container
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int> l2(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l2.cbegin(), std::next(l2.cbegin())),
"list::erase(iterator, iterator) called with an iterator not referring to this list");
}
// With an invalid range
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(l1.erase(std::next(l1.cbegin()), l1.cbegin()),
"Attempted to increment a non-incrementable list::const_iterator");
}
return 0;
}

View File

@ -11,24 +11,19 @@
// template <InputIterator Iter>
// iterator insert(const_iterator position, Iter first, Iter last);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**)
{
{
std::list<int> v(100);
std::list<int> v2(100);
int a[] = {1, 2, 3, 4, 5};
TEST_LIBCPP_ASSERT_FAILURE(v.insert(v2.cbegin(), a, a + 5),
"list::insert(iterator, range) called with an iterator not referring to this list");
}
int main(int, char**) {
std::list<int> v(100);
std::list<int> v2(100);
int a[] = {1, 2, 3, 4, 5};
TEST_LIBCPP_ASSERT_FAILURE(v.insert(v2.cbegin(), a, a + 5),
"list::insert(iterator, range) called with an iterator not referring to this list");
return 0;
return 0;
}

View File

@ -10,17 +10,14 @@
// iterator insert(const_iterator position, value_type&& x);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**)
{
int main(int, char**) {
std::list<int> v1(3);
std::list<int> v2(3);
TEST_LIBCPP_ASSERT_FAILURE(v1.insert(v2.begin(), 4),

View File

@ -10,17 +10,14 @@
// iterator insert(const_iterator position, size_type n, const value_type& x);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**)
{
int main(int, char**) {
std::list<int> c1(100);
std::list<int> c2;
TEST_LIBCPP_ASSERT_FAILURE(c1.insert(c2.cbegin(), 5, 1),

View File

@ -10,17 +10,14 @@
// iterator insert(const_iterator position, const value_type& x);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**)
{
int main(int, char**) {
std::list<int> v1(3);
std::list<int> v2(3);
int i = 4;

View File

@ -1,31 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <list>
// Call erase(const_iterator first, const_iterator last); with first iterator from another container
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**)
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int> l2(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l2.cbegin(), std::next(l1.cbegin())),
"list::erase(iterator, iterator) called with an iterator not referring to this list");
return 0;
}

View File

@ -1,31 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <list>
// Call erase(const_iterator first, const_iterator last); with second iterator from another container
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**)
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int> l2(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin(), std::next(l2.cbegin())),
"list::erase(iterator, iterator) called with an iterator not referring to this list");
return 0;
}

View File

@ -1,31 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <list>
// Call erase(const_iterator first, const_iterator last); with both iterators from another container
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**)
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int> l2(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l2.cbegin(), std::next(l2.cbegin())),
"list::erase(iterator, iterator) called with an iterator not referring to this list");
return 0;
}

View File

@ -1,30 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <list>
// Call erase(const_iterator first, const_iterator last); with a bad range
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**)
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(l1.erase(std::next(l1.cbegin()), l1.cbegin()),
"Attempted to increment a non-incrementable list::const_iterator");
return 0;
}

View File

@ -10,23 +10,17 @@
// void splice(const_iterator position, list& x);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**)
{
{
std::list<int> v1(3);
std::list<int> v2(3);
TEST_LIBCPP_ASSERT_FAILURE(v1.splice(v2.begin(), v2),
"list::splice(iterator, list) called with an iterator not referring to this list");
}
#include "check_assertion.h"
int main(int, char**) {
std::list<int> v1(3);
std::list<int> v2(3);
TEST_LIBCPP_ASSERT_FAILURE(v1.splice(v2.begin(), v2),
"list::splice(iterator, list) called with an iterator not referring to this list");
return 0;
}

View File

@ -10,24 +10,19 @@
// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**)
{
{
std::list<int> v1(3);
std::list<int> v2(3);
TEST_LIBCPP_ASSERT_FAILURE(
v1.splice(v1.begin(), v2, v1.begin()),
"list::splice(iterator, list, iterator) called with the second iterator not referring to the list argument");
}
int main(int, char**) {
std::list<int> v1(3);
std::list<int> v2(3);
TEST_LIBCPP_ASSERT_FAILURE(
v1.splice(v1.begin(), v2, v1.begin()),
"list::splice(iterator, list, iterator) called with the second iterator not referring to the list argument");
return 0;
}

View File

@ -10,24 +10,19 @@
// void splice(const_iterator position, list& x, iterator first, iterator last);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <list>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**)
{
{
std::list<int> v1(3);
std::list<int> v2(3);
TEST_LIBCPP_ASSERT_FAILURE(
v1.splice(v1.begin(), v2, v2.begin(), v1.end()),
"list::splice(iterator, list, iterator, iterator) called with third iterator not referring to the list argument");
}
int main(int, char**) {
std::list<int> v1(3);
std::list<int> v2(3);
TEST_LIBCPP_ASSERT_FAILURE(
v1.splice(v1.begin(), v2, v2.begin(), v1.end()),
"list::splice(iterator, list, iterator, iterator) called with third iterator not referring to the list argument");
return 0;
}

View File

@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Call back() on empty container.
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <vector>
#include <cassert>
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
assert(c.back() == 0);
c.clear();
TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector");
}
{
typedef int T;
typedef std::vector<T> C;
C c(1);
assert(c.back() == 0);
c.clear();
TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector");
}
return 0;
}

View File

@ -10,21 +10,28 @@
// Call back() on empty const container.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <vector>
#include "debug_macros.h"
#include "test_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
const C c;
TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector");
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
const C c;
TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector");
}
{
typedef int T;
typedef std::vector<T> C;
const C c;
TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector");
}
return 0;
}

View File

@ -10,21 +10,28 @@
// Call front() on empty const container.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <vector>
#include "debug_macros.h"
#include "test_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
const C c;
TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector");
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
const C c;
TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector");
}
{
typedef int T;
typedef std::vector<T> C;
const C c;
TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector");
}
return 0;
}

View File

@ -10,23 +10,31 @@
// Index const vector out of bounds.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <vector>
#include <cassert>
#include "debug_macros.h"
#include "test_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**)
{
int main(int, char**) {
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
const C c(1);
assert(c[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds");
}
{
typedef int T;
typedef std::vector<T> C;
const C c(1);
assert(c[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds");
}
return 0;
return 0;
}

View File

@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Call front() on empty container.
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <vector>
#include <cassert>
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
assert(c.front() == 0);
c.clear();
TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector");
}
{
typedef int T;
typedef std::vector<T> C;
C c(1);
assert(c.front() == 0);
c.clear();
TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector");
}
return 0;
}

View File

@ -10,23 +10,31 @@
// Index vector out of bounds.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
assert(c[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds");
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
assert(c[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds");
}
{
typedef int T;
typedef std::vector<T> C;
C c(1);
assert(c[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds");
}
return 0;
}

View File

@ -10,14 +10,12 @@
// pop_back() more than the number of elements in a vector
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <vector>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**) {
std::vector<int> v;

View File

@ -1,32 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Call back() on empty container.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T> C;
C c(1);
assert(c.back() == 0);
c.clear();
TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector");
return 0;
}

View File

@ -1,33 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Call back() on empty container.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
assert(c.back() == 0);
c.clear();
TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector");
return 0;
}

View File

@ -1,29 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Call back() on empty const container.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T> C;
const C c;
TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector");
return 0;
}

View File

@ -1,29 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Call front() on empty const container.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T> C;
const C c;
TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector");
return 0;
}

View File

@ -1,32 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Index const vector out of bounds.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "debug_macros.h"
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
const C c(1);
assert(c[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds");
return 0;
}

View File

@ -1,32 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Call front() on empty container.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T> C;
C c(1);
assert(c.front() == 0);
c.clear();
TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector");
return 0;
}

View File

@ -1,33 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Call front() on empty container.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
assert(c.front() == 0);
c.clear();
TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector");
return 0;
}

View File

@ -1,31 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Index vector out of bounds.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T> C;
C c(1);
assert(c[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds");
return 0;
}

View File

@ -1,35 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Add to iterator out of bounds.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
C::iterator i = c.begin();
i += 1;
assert(i == c.end());
i = c.begin();
TEST_LIBCPP_ASSERT_FAILURE(i + 2, "Attempted to add/subtract an iterator outside its valid range");
return 0;
}

View File

@ -1,34 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Increment iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
C::iterator i = c.begin();
++i;
assert(i == c.end());
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
return 0;
}

View File

@ -1,31 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include "test_macros.h"
#include "debug_macros.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
C::iterator i = c.end();
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator");
return 0;
}

View File

@ -1,30 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Compare iterators from different containers with <.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T> C;
C c1;
C c2;
TEST_LIBCPP_ASSERT_FAILURE(c1.begin() < c2.begin(), "Attempted to compare incomparable iterators");
return 0;
}

View File

@ -1,30 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Subtract iterators from different containers.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T> C;
C c1;
C c2;
TEST_LIBCPP_ASSERT_FAILURE(c1.begin() - c2.begin(), "Attempted to subtract incompatible iterators");
return 0;
}

View File

@ -1,32 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Index iterator out of bounds.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T> C;
C c(1);
C::iterator i = c.begin();
assert(i[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(i[1], "Attempted to subscript an iterator outside its valid range");
return 0;
}

View File

@ -1,34 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Add to iterator out of bounds.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T> C;
C c(1);
C::iterator i = c.begin();
i += 1;
assert(i == c.end());
i = c.begin();
TEST_LIBCPP_ASSERT_FAILURE(i + 2, "Attempted to add/subtract an iterator outside its valid range");
return 0;
}

View File

@ -1,33 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Decrement iterator prior to begin.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T> C;
C c(1);
C::iterator i = c.end();
--i;
assert(i == c.begin());
TEST_LIBCPP_ASSERT_FAILURE(--i, "Attempted to decrement a non-decrementable iterator");
return 0;
}

View File

@ -1,33 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Increment iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T> C;
C c(1);
C::iterator i = c.begin();
++i;
assert(i == c.end());
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
return 0;
}

View File

@ -1,30 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T> C;
C c(1);
C::iterator i = c.end();
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator");
return 0;
}

View File

@ -0,0 +1,46 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Add to iterator out of bounds.
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
{
typedef int T;
typedef std::vector<T> C;
C c(1);
C::iterator i = c.begin();
i += 1;
assert(i == c.end());
i = c.begin();
TEST_LIBCPP_ASSERT_FAILURE(i + 2, "Attempted to add/subtract an iterator outside its valid range");
}
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
C::iterator i = c.begin();
i += 1;
assert(i == c.end());
i = c.begin();
TEST_LIBCPP_ASSERT_FAILURE(i + 2, "Attempted to add/subtract an iterator outside its valid range");
}
return 0;
}

View File

@ -10,22 +10,30 @@
// Compare iterators from different containers with <.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c1;
C c2;
TEST_LIBCPP_ASSERT_FAILURE(c1.begin() < c2.begin(), "Attempted to compare incomparable iterators");
{
typedef int T;
typedef std::vector<T> C;
C c1;
C c2;
TEST_LIBCPP_ASSERT_FAILURE(c1.begin() < c2.begin(), "Attempted to compare incomparable iterators");
}
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c1;
C c2;
TEST_LIBCPP_ASSERT_FAILURE(c1.begin() < c2.begin(), "Attempted to compare incomparable iterators");
}
return 0;
}

View File

@ -10,25 +10,35 @@
// Decrement iterator prior to begin.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
C::iterator i = c.end();
--i;
assert(i == c.begin());
TEST_LIBCPP_ASSERT_FAILURE(--i, "Attempted to decrement a non-decrementable iterator");
{
typedef int T;
typedef std::vector<T> C;
C c(1);
C::iterator i = c.end();
--i;
assert(i == c.begin());
TEST_LIBCPP_ASSERT_FAILURE(--i, "Attempted to decrement a non-decrementable iterator");
}
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
C::iterator i = c.end();
--i;
assert(i == c.begin());
TEST_LIBCPP_ASSERT_FAILURE(--i, "Attempted to decrement a non-decrementable iterator");
}
return 0;
}

View File

@ -6,27 +6,34 @@
//
//===----------------------------------------------------------------------===//
// <unordered_set>
// <vector>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_set>
#include <vector>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
{
typedef int T;
typedef std::unordered_set<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C;
typedef std::vector<T> C;
C c(1);
C::iterator i = c.end();
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container const_iterator");
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator");
}
return 0;
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
C::iterator i = c.end();
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator");
}
return 0;
}

View File

@ -6,31 +6,39 @@
//
//===----------------------------------------------------------------------===//
// <unordered_set>
// <vector>
// Increment iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_set>
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
{
typedef int T;
typedef std::unordered_set<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C;
C c({42});
typedef std::vector<T> C;
C c(1);
C::iterator i = c.begin();
assert(i != c.end());
++i;
assert(i == c.end());
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container const_iterator");
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
}
return 0;
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
C::iterator i = c.begin();
++i;
assert(i == c.end());
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
}
return 0;
}

View File

@ -10,24 +10,33 @@
// Index iterator out of bounds.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
C::iterator i = c.begin();
assert(i[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(i[1], "Attempted to subscript an iterator outside its valid range");
{
typedef int T;
typedef std::vector<T> C;
C c(1);
C::iterator i = c.begin();
assert(i[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(i[1], "Attempted to subscript an iterator outside its valid range");
}
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c(1);
C::iterator i = c.begin();
assert(i[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(i[1], "Attempted to subscript an iterator outside its valid range");
}
return 0;
}

View File

@ -10,22 +10,30 @@
// Subtract iterators from different containers.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c1;
C c2;
TEST_LIBCPP_ASSERT_FAILURE(c1.begin() - c2.begin(), "Attempted to subtract incompatible iterators");
{
typedef int T;
typedef std::vector<T> C;
C c1;
C c2;
TEST_LIBCPP_ASSERT_FAILURE(c1.begin() - c2.begin(), "Attempted to subtract incompatible iterators");
}
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c1;
C c2;
TEST_LIBCPP_ASSERT_FAILURE(c1.begin() - c2.begin(), "Attempted to subtract incompatible iterators");
}
return 0;
}

View File

@ -10,15 +10,13 @@
// size_type bucket(const key_type& __k) const;
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <unordered_map>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**) {
typedef std::unordered_map<int, std::string> C;

View File

@ -14,15 +14,13 @@
// size_type bucket_size(size_type n) const
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <unordered_map>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**) {
typedef std::unordered_map<int, std::string> C;

View File

@ -15,15 +15,13 @@
// float max_load_factor() const;
// void max_load_factor(float mlf);
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <unordered_map>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**) {
typedef std::unordered_map<int, std::string> C;

View File

@ -1,34 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Increment iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <cassert>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::unordered_map<int, std::string> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.begin();
++i;
assert(i == c.end());
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container iterator");
return 0;
}

View File

@ -1,31 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::unordered_map<int, std::string> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.end();
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container iterator");
return 0;
}

View File

@ -1,37 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Increment iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <cassert>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
#include "min_allocator.h"
int main(int, char**) {
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.begin();
++i;
assert(i == c.end());
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container iterator");
return 0;
}

View File

@ -1,33 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
#include "min_allocator.h"
int main(int, char**) {
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c(1);
C::local_iterator i = c.end(0);
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container local_iterator");
return 0;
}

View File

@ -1,36 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Increment local_iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <string>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::unordered_map<int, std::string> C;
C c;
c.insert(std::make_pair(42, std::string()));
C::size_type b = c.bucket(42);
C::local_iterator i = c.begin(b);
assert(i != c.end(b));
++i;
assert(i == c.end(b));
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container local_iterator");
return 0;
}

View File

@ -1,30 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::unordered_map<int, std::string> C;
C c(1);
C::local_iterator i = c.end(0);
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container local_iterator");
return 0;
}

View File

@ -1,38 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Increment local_iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <string>
#include <cassert>
#include "test_macros.h"
#include "debug_macros.h"
#include "min_allocator.h"
int main(int, char**) {
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c({{42, std::string()}});
C::size_type b = c.bucket(42);
C::local_iterator i = c.begin(b);
assert(i != c.end(b));
++i;
assert(i == c.end(b));
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container local_iterator");
return 0;
}

View File

@ -10,14 +10,13 @@
// iterator insert(const_iterator p, const value_type& x);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "check_assertion.h"
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::unordered_map<double, int> C;

View File

@ -6,22 +6,19 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// <unordered_map>
// template <class P,
// class = typename enable_if<is_convertible<P, value_type>::value>::type>
// iterator insert(const_iterator p, P&& x);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "check_assertion.h"
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::unordered_map<double, int> C;

View File

@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <string>
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
{
typedef std::unordered_map<int, std::string> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.end();
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container iterator");
}
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.end();
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container iterator");
}
return 0;
}

View File

@ -0,0 +1,46 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Increment iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <cassert>
#include <string>
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
{
typedef std::unordered_map<int, std::string> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.begin();
++i;
assert(i == c.end());
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container iterator");
}
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.begin();
++i;
assert(i == c.end());
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container iterator");
}
return 0;
}

View File

@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <string>
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
{
typedef std::unordered_map<int, std::string> C;
C c(1);
C::local_iterator i = c.end(0);
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container local_iterator");
}
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c(1);
C::local_iterator i = c.end(0);
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container local_iterator");
}
return 0;
}

View File

@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Increment local_iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <string>
#include <cassert>
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
{
typedef std::unordered_map<int, std::string> C;
C c;
c.insert(std::make_pair(42, std::string()));
C::size_type b = c.bucket(42);
C::local_iterator i = c.begin(b);
assert(i != c.end(b));
++i;
assert(i == c.end(b));
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container local_iterator");
}
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c({{42, std::string()}});
C::size_type b = c.bucket(42);
C::local_iterator i = c.begin(b);
assert(i != c.end(b));
++i;
assert(i == c.end(b));
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container local_iterator");
}
return 0;
}

View File

@ -14,14 +14,12 @@
// void swap(unordered_map& x, unordered_map& y);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**) {
typedef std::pair<int, int> P;

View File

@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Call erase(const_iterator position) with invalid iterators
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "check_assertion.h"
int main(int, char**) {
// With end()
{
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_map<int, int> l1(a1, a1+3);
std::unordered_map<int, int>::const_iterator i = l1.end();
TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i),
"unordered container erase(iterator) called with a non-dereferenceable iterator");
}
// With iterator from another container
{
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_map<int, int> l1(a1, a1+3);
std::unordered_map<int, int> l2(a1, a1+3);
std::unordered_map<int, int>::const_iterator i = l2.begin();
TEST_LIBCPP_ASSERT_FAILURE(
l1.erase(i), "unordered container erase(iterator) called with an iterator not referring to this container");
}
return 0;
}

View File

@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Call erase(const_iterator first, const_iterator last); with invalid iterators
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "check_assertion.h"
int main(int, char**) {
// First iterator from a different container
{
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_map<int, int> l1(a1, a1+3);
std::unordered_map<int, int> l2(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(
l1.erase(l2.cbegin(), std::next(l1.cbegin())),
"unordered container::erase(iterator, iterator) called with an iterator not referring to this container");
}
// Second iterator from a different container
{
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_map<int, int> l1(a1, a1+3);
std::unordered_map<int, int> l2(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(
l1.erase(l1.cbegin(), std::next(l2.cbegin())),
"unordered container::erase(iterator, iterator) called with an iterator not referring to this container");
}
// Both iterators from a different container
{
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_map<int, int> l1(a1, a1+3);
std::unordered_map<int, int> l2(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(
l1.erase(l2.cbegin(), std::next(l2.cbegin())),
"unordered container::erase(iterator, iterator) called with an iterator not referring to this container");
}
// With iterators that don't form a valid range
{
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_map<int, int> l1(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(l1.erase(std::next(l1.cbegin()), l1.cbegin()),
"Attempted to increment a non-incrementable unordered container const_iterator");
}
return 0;
}

View File

@ -1,31 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Call erase(const_iterator position) with end()
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_map<int, int> l1(a1, a1+3);
std::unordered_map<int, int>::const_iterator i = l1.end();
TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i),
"unordered container erase(iterator) called with a non-dereferenceable iterator");
return 0;
}

View File

@ -1,32 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Call erase(const_iterator position) with iterator from another container
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_map<int, int> l1(a1, a1+3);
std::unordered_map<int, int> l2(a1, a1+3);
std::unordered_map<int, int>::const_iterator i = l2.begin();
TEST_LIBCPP_ASSERT_FAILURE(
l1.erase(i), "unordered container erase(iterator) called with an iterator not referring to this container");
return 0;
}

View File

@ -1,32 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Call erase(const_iterator first, const_iterator last); with first iterator from another container
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_map<int, int> l1(a1, a1+3);
std::unordered_map<int, int> l2(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(
l1.erase(l2.cbegin(), std::next(l1.cbegin())),
"unordered container::erase(iterator, iterator) called with an iterator not referring to this container");
return 0;
}

View File

@ -1,32 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Call erase(const_iterator first, const_iterator last); with second iterator from another container
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_map<int, int> l1(a1, a1+3);
std::unordered_map<int, int> l2(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(
l1.erase(l1.cbegin(), std::next(l2.cbegin())),
"unordered container::erase(iterator, iterator) called with an iterator not referring to this container");
return 0;
}

View File

@ -1,32 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Call erase(const_iterator first, const_iterator last); with both iterators from another container
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_map<int, int> l1(a1, a1+3);
std::unordered_map<int, int> l2(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(
l1.erase(l2.cbegin(), std::next(l2.cbegin())),
"unordered container::erase(iterator, iterator) called with an iterator not referring to this container");
return 0;
}

View File

@ -1,30 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Call erase(const_iterator first, const_iterator last); with a bad range
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_map<int, int> l1(a1, a1+3);
TEST_LIBCPP_ASSERT_FAILURE(l1.erase(std::next(l1.cbegin()), l1.cbegin()),
"Attempted to increment a non-incrementable unordered container const_iterator");
return 0;
}

View File

@ -14,15 +14,13 @@
// size_type bucket(const key_type& __k) const;
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <unordered_map>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**) {
typedef std::unordered_multimap<int, std::string> C;

View File

@ -14,15 +14,13 @@
// size_type bucket_size(size_type n) const
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <unordered_map>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**) {
typedef std::unordered_multimap<int, std::string> C;

View File

@ -15,15 +15,13 @@
// float max_load_factor() const;
// void max_load_factor(float mlf);
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
#include <unordered_map>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**) {
typedef std::unordered_multimap<int, std::string> C;

View File

@ -1,34 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <string>
#include <unordered_map>
#include "test_macros.h"
#include "debug_macros.h"
#include "min_allocator.h"
int main(int, char**) {
typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.end();
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container iterator");
return 0;
}

View File

@ -1,34 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Increment iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <cassert>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::unordered_multimap<int, std::string> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.begin();
++i;
assert(i == c.end());
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container iterator");
return 0;
}

View File

@ -1,31 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <string>
#include <unordered_map>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::unordered_multimap<int, std::string> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.end();
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container iterator");
return 0;
}

View File

@ -1,33 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
#include "min_allocator.h"
int main(int, char**) {
typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c(1);
C::local_iterator i = c.end(0);
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container local_iterator");
return 0;
}

View File

@ -1,36 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Increment local_iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <cassert>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::unordered_multimap<int, std::string> C;
C c;
c.insert(std::make_pair(42, std::string()));
C::size_type b = c.bucket(42);
C::local_iterator i = c.begin(b);
assert(i != c.end(b));
++i;
assert(i == c.end(b));
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container local_iterator");
return 0;
}

View File

@ -1,30 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
int main(int, char**) {
typedef std::unordered_multimap<int, std::string> C;
C c(1);
C::local_iterator i = c.end(0);
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container local_iterator");
return 0;
}

View File

@ -1,39 +0,0 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Increment local_iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <cassert>
#include <string>
#include "test_macros.h"
#include "debug_macros.h"
#include "min_allocator.h"
int main(int, char**) {
typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c({{1, std::string()}});
c.insert(std::make_pair(42, std::string()));
C::size_type b = c.bucket(42);
C::local_iterator i = c.begin(b);
assert(i != c.end(b));
++i;
assert(i == c.end(b));
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container local_iterator");
return 0;
}

View File

@ -10,14 +10,12 @@
// iterator insert(const_iterator p, const value_type& x);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**) {
typedef std::unordered_multimap<double, int> C;

View File

@ -6,22 +6,18 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// <unordered_map>
// template <class P,
// class = typename enable_if<is_convertible<P, value_type>::value>::type>
// iterator insert(const_iterator p, P&& x);
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
int main(int, char**) {
typedef std::unordered_multimap<double, int> C;

View File

@ -0,0 +1,41 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Dereference non-dereferenceable iterator.
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <string>
#include <unordered_map>
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
{
typedef std::unordered_multimap<int, std::string> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.end();
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container iterator");
}
{
typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.end();
TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container iterator");
}
return 0;
}

View File

@ -0,0 +1,46 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <unordered_map>
// Increment iterator past end.
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <unordered_map>
#include <cassert>
#include <string>
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
{
typedef std::unordered_multimap<int, std::string> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.begin();
++i;
assert(i == c.end());
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container iterator");
}
{
typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
C c;
c.insert(std::make_pair(1, "one"));
C::iterator i = c.begin();
++i;
assert(i == c.end());
TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container iterator");
}
return 0;
}

Some files were not shown because too many files have changed in this diff Show More