Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// 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 <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(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_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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@

// void swap(unordered_multimap& x, unordered_multimap& 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**)
{
int main(int, char**) {
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(3, 3), P(7, 7), P(9, 9), P(10, 10)};
P a2[] = {P(0, 0), P(2, 2), P(4, 4), P(5, 5), P(6, 6), P(8, 8), P(11, 11)};
Expand Down
Original file line number Diff line number Diff line change
@@ -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_multimap<int, int> l1(a1, a1+3);
std::unordered_multimap<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_multimap<int, int> l1(a1, a1+3);
std::unordered_multimap<int, int> l2(a1, a1+3);
std::unordered_multimap<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;
}
Original file line number Diff line number Diff line change
@@ -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**) {
// With first iterator from another container
{
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_multimap<int, int> l1(a1, a1+3);
std::unordered_multimap<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");
}

// With second iterator from another container
{
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_multimap<int, int> l1(a1, a1+3);
std::unordered_multimap<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");
}

// With both iterators from another container
{
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_multimap<int, int> l1(a1, a1+3);
std::unordered_multimap<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 an invalid range
{
typedef std::pair<int, int> P;
P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
std::unordered_multimap<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;
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@

// 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_set>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"

int main(int, char**) {
typedef std::unordered_multiset<int> C;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@

// 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_set>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"

int main(int, char**) {
typedef std::unordered_multiset<int> C;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
// 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_set>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"

int main(int, char**) {
typedef std::unordered_multiset<int> C;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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_set>

// 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_set>

#include "check_assertion.h"

int main(int, char**) {
// With end()
{
int a1[] = {1, 2, 3};
std::unordered_multiset<int> l1(a1, a1+3);
std::unordered_multiset<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
{
int a1[] = {1, 2, 3};
std::unordered_multiset<int> l1(a1, a1+3);
std::unordered_multiset<int> l2(a1, a1+3);
std::unordered_multiset<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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//===----------------------------------------------------------------------===//
//
// 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_set>

// 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_set>

#include "check_assertion.h"

int main(int, char**) {
// With first iterator from another container
{
int a1[] = {1, 2, 3};
std::unordered_multiset<int> l1(a1, a1+3);
std::unordered_multiset<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");
}

// With second iterator from another container
{
int a1[] = {1, 2, 3};
std::unordered_multiset<int> l1(a1, a1+3);
std::unordered_multiset<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");
}

// With both iterators from another container
{
int a1[] = {1, 2, 3};
std::unordered_multiset<int> l1(a1, a1+3);
std::unordered_multiset<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 an invalid range
{
int a1[] = {1, 2, 3};
std::unordered_multiset<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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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_set>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"

int main(int, char**) {
typedef std::unordered_multiset<double> C;
Expand Down
Original file line number Diff line number Diff line change
@@ -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_set>

// Dereference non-dereferenceable iterator.

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1

#include <unordered_set>

#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
{
typedef int T;
typedef std::unordered_multiset<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");
}

{
typedef int T;
typedef std::unordered_multiset<T, std::hash<T>, std::equal_to<T>, min_allocator<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");
}

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// 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_set>

// Increment iterator past end.

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1

#include <unordered_set>
#include <cassert>

#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
{
typedef int T;
typedef std::unordered_multiset<T> C;
C c;
c.insert(42);
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");
}

{
typedef int T;
typedef std::unordered_multiset<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C;
C c({42});
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");
}

return 0;
}
Original file line number Diff line number Diff line change
@@ -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_set>

// Dereference non-dereferenceable iterator.

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1

#include <unordered_set>

#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
{
typedef int T;
typedef std::unordered_multiset<T> C;
C c(1);
C::local_iterator i = c.end(0);
TEST_LIBCPP_ASSERT_FAILURE(
*i, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
}

{
typedef int T;
typedef std::unordered_multiset<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C;
C c(1);
C::local_iterator i = c.end(0);
TEST_LIBCPP_ASSERT_FAILURE(
*i, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
}

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// 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_set>

// Increment local_iterator past end.

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1

#include <unordered_set>
#include <cassert>

#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
{
typedef int T;
typedef std::unordered_multiset<T> C;
C c;
c.insert(42);
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 const_local_iterator");
}

{
typedef int T;
typedef std::unordered_multiset<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C;
C c({42});
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 const_local_iterator");
}

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@

// void swap(unordered_multiset& x, unordered_multiset& y);

// UNSUPPORTED: libcxx-no-debug-mode

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1

#include <unordered_set>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"

int main(int, char**) {
int a1[] = {1, 3, 7, 9, 10};
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@

// 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_set>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"

int main(int, char**) {
typedef std::unordered_set<int> C;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@

// 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_set>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"

int main(int, char**) {
typedef std::unordered_set<int> C;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
// 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_set>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"

int main(int, char**) {
typedef std::unordered_set<int> C;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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_set>

// 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_set>

#include "check_assertion.h"

int main(int, char**) {
// With end()
{
int a1[] = {1, 2, 3};
std::unordered_set<int> l1(a1, a1+3);
std::unordered_set<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
{
int a1[] = {1, 2, 3};
std::unordered_set<int> l1(a1, a1+3);
std::unordered_set<int> l2(a1, a1+3);
std::unordered_set<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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//===----------------------------------------------------------------------===//
//
// 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_set>

// Call erase(const_iterator first, const_iterator last); with first iterator from another container

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1

#include <unordered_set>

#include "check_assertion.h"

int main(int, char**) {
// With first iterator from another container
{
int a1[] = {1, 2, 3};
std::unordered_set<int> l1(a1, a1+3);
std::unordered_set<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");
}

// With second iterator from another container
{
int a1[] = {1, 2, 3};
std::unordered_set<int> l1(a1, a1+3);
std::unordered_set<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");
}

// With both iterators from another container
{
int a1[] = {1, 2, 3};
std::unordered_set<int> l1(a1, a1+3);
std::unordered_set<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 an invalid range
{
int a1[] = {1, 2, 3};
std::unordered_set<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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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_set>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"

int main(int, char**) {
typedef std::unordered_set<double> C;
Expand Down
Original file line number Diff line number Diff line change
@@ -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_set>

// Dereference non-dereferenceable iterator.

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1

#include <unordered_set>

#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
{
typedef int T;
typedef std::unordered_set<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");
}

{
typedef int T;
typedef std::unordered_set<T, std::hash<T>, std::equal_to<T>, min_allocator<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");
}

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// 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_set>

// Increment iterator past end.

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1

#include <unordered_set>
#include <cassert>

#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
{
typedef int T;
typedef std::unordered_set<T> C;
C c;
c.insert(42);
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");
}

{
typedef int T;
typedef std::unordered_set<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C;
C c({42});
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");
}

return 0;
}
Original file line number Diff line number Diff line change
@@ -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_set>

// Dereference non-dereferenceable iterator.

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1

#include <unordered_set>

#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
{
typedef int T;
typedef std::unordered_set<T> C;
C c(1);
C::local_iterator i = c.end(0);
TEST_LIBCPP_ASSERT_FAILURE(
*i, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
}

{
typedef int T;
typedef std::unordered_set<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C;
C c(1);
C::local_iterator i = c.end(0);
TEST_LIBCPP_ASSERT_FAILURE(
*i, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
}

return 0;
}
Original file line number Diff line number Diff line change
@@ -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_set>

// Increment local_iterator past end.

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1

#include <unordered_set>
#include <cassert>

#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
{
typedef int T;
typedef std::unordered_set<T> C;
C c;
c.insert(42);
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 const_local_iterator");
}

{
typedef int T;
typedef std::unordered_set<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C;
C c({42});
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 const_local_iterator");
}

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@

// void swap(unordered_set& x, unordered_set& y);

// UNSUPPORTED: libcxx-no-debug-mode

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1

#include <unordered_set>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"

int main(int, char**) {
int a1[] = {1, 3, 7, 9, 10};
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03
// UNSUPPORTED: windows

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: libcxx-no-debug-mode

#include <__debug>
#include "debug_mode_helper.h"

#include <cstdio>
#include "test_macros.h"

#include "check_assertion.h"
#include "test_macros.h"

template <class Func>
inline bool TestDeathTest(const char* stmt, Func&& func, DeathTest::ResultKind ExpectResult, DebugInfoMatcher Matcher = AnyMatcher) {
Expand Down Expand Up @@ -58,8 +54,7 @@ void test_unknown() {
TEST_DEATH_TEST(DeathTest::RK_Unknown, std::exit(13));
}

int main(int, char**)
{
int main(int, char**) {
test_no_match_found();
test_did_not_die();
test_unknown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14
// UNSUPPORTED: windows
// UNSUPPORTED: c++11, c++14
// UNSUPPORTED: libcpp-has-no-threads

// UNSUPPORTED: libcxx-no-debug-mode, c++03
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: libcxx-no-debug-mode

// test multihtreaded container debugging
// test multithreaded container debugging

#include <cassert>
#include <cstddef>
#include <deque>
#include <list>
#include <thread>
#include <vector>
#include "container_debug_tests.h"

#include "test_macros.h"


template <typename Container>
Container makeContainer(int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14
// UNSUPPORTED: windows
// UNSUPPORTED: c++11, c++14

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: libcxx-no-debug-mode

// test container debugging

#include <map>
#include <set>
#include <utility>
#include <cassert>
#include "check_assertion.h"
#include "container_debug_tests.h"
#include "test_macros.h"
#include "debug_mode_helper.h"

using namespace IteratorDebugChecks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14
// UNSUPPORTED: windows
// UNSUPPORTED: c++11, c++14

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: libcxx-no-debug-mode

// test container debugging

#include <forward_list>
#include <list>
#include <vector>
#include <deque>
#include "check_assertion.h"
#include "container_debug_tests.h"
#include "test_macros.h"
#include "debug_mode_helper.h"

using namespace IteratorDebugChecks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14
// UNSUPPORTED: windows
// UNSUPPORTED: c++11, c++14

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: libcxx-no-debug-mode

// test container debugging

#include <string>
#include <vector>

#include "test_macros.h"
#include "check_assertion.h"
#include "container_debug_tests.h"
#include "debug_mode_helper.h"

using namespace IteratorDebugChecks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14
// UNSUPPORTED: windows
// UNSUPPORTED: c++11, c++14

// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
// UNSUPPORTED: libcxx-no-debug-mode

// test container debugging

#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <cassert>
#include "check_assertion.h"
#include "container_debug_tests.h"
#include "test_macros.h"
#include "debug_mode_helper.h"

using namespace IteratorDebugChecks;

Expand Down
42 changes: 0 additions & 42 deletions libcxx/test/libcxx/debug/db_string_view.pass.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion libcxx/test/libcxx/debug/debug_abort.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
// UNSUPPORTED: libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1

// Test that the default debug handler aborts the program.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,25 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// <experimental/memory_resource>

// template <class T> class polymorphic_allocator

// T* polymorphic_allocator<T>::deallocate(T*, size_t size)

// 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 <experimental/memory_resource>
#include <type_traits>
#include <cassert>

#include "check_assertion.h"
#include "test_memory_resource.h"

#include "test_macros.h"
#include "debug_macros.h"

namespace ex = std::experimental::pmr;

int main(int, char**)
{
int main(int, char**) {
using Alloc = ex::polymorphic_allocator<int>;
using Traits = std::allocator_traits<Alloc>;
NullResource R;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,25 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// <experimental/memory_resource>

// template <class T> class polymorphic_allocator

// T* polymorphic_allocator<T>::deallocate(T*, size_t size)

// 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 <experimental/memory_resource>
#include <type_traits>
#include <cassert>

#include "check_assertion.h"
#include "test_memory_resource.h"

#include "test_macros.h"
#include "debug_macros.h"

namespace ex = std::experimental::pmr;

int main(int, char**)
{
int main(int, char**) {
using Alloc = NullAllocator<char>;

AllocController P;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03
// UNSUPPORTED: windows
// UNSUPPORTED: libcxx-no-debug-mode

// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0

// <filesystem>

Expand All @@ -21,33 +18,28 @@
#include <type_traits>
#include <cassert>

#include "test_macros.h"
#include "debug_mode_helper.h"
#include "check_assertion.h"

int main(int, char**) {
using namespace fs;
// Test incrementing/decrementing a singular iterator
{
path::iterator singular;
EXPECT_DEATH( ++singular );
EXPECT_DEATH( --singular );
fs::path::iterator singular;
TEST_LIBCPP_ASSERT_FAILURE(++singular, "attempting to increment a singular iterator");
TEST_LIBCPP_ASSERT_FAILURE(--singular, "attempting to decrement a singular iterator");
}
// Test decrementing the begin iterator

// Test incrementing the end iterator
{
path p("foo/bar");
fs::path p("foo/bar");
auto it = p.begin();
++it;
++it;
EXPECT_DEATH( ++it );
TEST_LIBCPP_ASSERT_FAILURE(--it, "attempting to decrement the begin iterator");
}

// Test incrementing the end iterator
{
path p("foo/bar");
fs::path p("foo/bar");
auto it = p.end();
EXPECT_DEATH( ++it );
--it;
--it;
EXPECT_DEATH( --it );
TEST_LIBCPP_ASSERT_FAILURE(++it, "attempting to increment the end iterator");
}

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03
// UNSUPPORTED: windows
// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0

// <list>

// Call advance(non-bidi iterator, -1)

#include <iterator>
#include "test_macros.h"
#include "debug_mode_helper.h"

#include "check_assertion.h"
#include "test_iterators.h"

int main(int, char**)
{
int main(int, char**) {
int a[] = {1, 2, 3};

bidirectional_iterator<int *> bidi(a+1);
Expand All @@ -33,7 +29,7 @@ int main(int, char**)
forward_iterator<int *> it(a+1);
std::advance(it, 1); // should work fine
std::advance(it, 0); // should work fine
EXPECT_DEATH( std::advance(it, -1) ); // can't go backwards on a FwdIter
TEST_LIBCPP_ASSERT_FAILURE(std::advance(it, -1), "Attempt to advance(it, n) with negative n on a non-bidirectional iterator");

return 0;
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,24 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03
// UNSUPPORTED: windows
// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0

// <list>

// Call next(non-bidi iterator, -1)

#include <iterator>
#include "test_macros.h"
#include "debug_mode_helper.h"

#include "check_assertion.h"
#include "test_iterators.h"

int main(int, char**)
{
int main(int, char**) {
int a[] = {1, 2, 3};


forward_iterator<int *> it(a+1);
std::next(it, 1); // should work fine
std::next(it, 0); // should work fine
EXPECT_DEATH( std::next(it, -1) ); // can't go backwards on a FwdIter
TEST_LIBCPP_ASSERT_FAILURE(std::next(it, -1), "Attempt to next(it, n) with negative n on a non-bidirectional iterator");

return 0;
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03
// UNSUPPORTED: windows
// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
// UNSUPPORTED: libcxx-no-debug-mode
// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0

// <list>

// Call prev(forward_iterator, -1)

#include <iterator>
#include "test_macros.h"
#include "debug_mode_helper.h"

#include "check_assertion.h"
#include "test_iterators.h"

int main(int, char**)
{
int main(int, char**) {
int a[] = {1, 2, 3};

bidirectional_iterator<int *> bidi(a+1);
Expand All @@ -33,7 +29,7 @@ int main(int, char**)
forward_iterator<int *> it(a+1);
std::prev(it, -1); // should work fine
std::prev(it, 0); // should work fine
EXPECT_DEATH( std::prev(it, 1) ); // can't go backwards on a FwdIter
TEST_LIBCPP_ASSERT_FAILURE(std::prev(it, 1), "Attempt to prev(it, n) with a positive n on a non-bidirectional iterator");

return 0;
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,25 @@

// Call back() on empty 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 <string>
#include <cassert>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
S s(1, '\0');
assert(s.back() == 0);
s.clear();
TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");

return 0;
{
std::string s;
TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
}

{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
S s;
TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
}

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,25 @@

// 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 <string>

#include "debug_macros.h"
#include "test_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
const S s;
TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");

return 0;
{
std::string const s;
TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
}

{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
const S s;
TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
}

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@

// 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 <string>

#include "debug_macros.h"
#include "test_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
const S s;
TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
{
typedef std::string S;
const S s;
TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
}

{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
const S s;
TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
}

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,29 @@

// Index const string 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 <string>
#include <cassert>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
const S s;
assert(s[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
const S s;
assert(s[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
}

{
typedef std::string S;
const S s;
assert(s[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
}

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,27 @@

// Call front() on empty 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 <string>
#include <cassert>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
S s(1, '\0');
assert(s.front() == 0);
s.clear();
TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
{
typedef std::string S;
S s;
TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
}

{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
S s;
TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
}

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,29 @@

// Index string 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 <string>
#include <cassert>

#include "test_macros.h"
#include "debug_macros.h"
#include "check_assertion.h"
#include "min_allocator.h"

int main(int, char**) {
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
S s;
assert(s[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
{
typedef std::string S;
S s;
assert(s[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
}

{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
S s;
assert(s[0] == 0);
TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
}

return 0;
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading