--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
// __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>
#include <cassert>
#include "test_macros.h"
-#include "debug_macros.h"
+#include "check_assertion.h"
template <int ID>
struct MyType {
}
};
-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 {
}
}
-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) {}
int main(int, char**) {
test_passing();
- test_failing();
test_upper_and_lower_bound();
test_non_const_arg_cmp();
test_value_iterator();
// 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>
// 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>
// 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>
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// pop_back() more than the number of elements in a deque
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <deque>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ std::deque<int> q;
+ q.push_back(0);
+ q.pop_back();
+ TEST_LIBCPP_ASSERT_FAILURE(q.pop_back(), "deque::pop_back called on an empty deque");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <deque>
-
-// pop_back() more than the number of elements in a deque
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <deque>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- std::deque<int> q;
- q.push_back(0);
- q.pop_back();
- TEST_LIBCPP_ASSERT_FAILURE(q.pop_back(), "deque::pop_back called on an empty deque");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// list(list&& c);
-
-// 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**)
-{
- std::list<int> l1;
- l1.push_back(1); l1.push_back(2); l1.push_back(3);
- std::list<int>::iterator i = l1.begin();
- std::list<int> l2 = l1;
- TEST_LIBCPP_ASSERT_FAILURE(l2.erase(i), "list::erase(iterator) called with an iterator not referring to this list");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// list(list&& c);
+
+// 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**) {
+ std::list<int> l1;
+ l1.push_back(1); l1.push_back(2); l1.push_back(3);
+ std::list<int>::iterator i = l1.begin();
+ std::list<int> l2 = l1;
+ TEST_LIBCPP_ASSERT_FAILURE(l2.erase(i), "list::erase(iterator) called with an iterator not referring to this list");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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 position) with end()
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <list>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::const_iterator i = l1.end();
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "list::erase(iterator) called with a non-dereferenceable iterator");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// void pop_back();
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <list>
+#include <cassert>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ int a[] = {1, 2, 3};
+ std::list<int> c(a, a+3);
+ c.pop_back();
+ assert(c == std::list<int>(a, a+2));
+ c.pop_back();
+ assert(c == std::list<int>(a, a+1));
+ c.pop_back();
+ assert(c.empty());
+ TEST_LIBCPP_ASSERT_FAILURE(c.pop_back(), "list::pop_back() called on an empty list");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class... Args> void emplace(const_iterator p, Args&&... args);
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <list>
+
+#include "check_assertion.h"
+
+struct A {
+ explicit A(int i, double d) {
+ (void)i;
+ (void)d;
+ }
+};
+
+int main(int, char**) {
+ std::list<A> c1;
+ std::list<A> c2;
+ TEST_LIBCPP_ASSERT_FAILURE(c1.emplace(c2.cbegin(), 2, 3.5),
+ "list::emplace(iterator, args...) called with an iterator not referring to this list");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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 position) with iterator from another container
+
+// 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**) {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::const_iterator i = l2.begin();
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "list::erase(iterator) called with an iterator not referring to this list");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <InputIterator Iter>
+// iterator insert(const_iterator position, Iter first, Iter last);
+
+// 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**) {
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// iterator insert(const_iterator position, value_type&& x);
+
+// 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**) {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ TEST_LIBCPP_ASSERT_FAILURE(v1.insert(v2.begin(), 4),
+ "list::insert(iterator, x) called with an iterator not referring to this list");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+// 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**) {
+ std::list<int> c1(100);
+ std::list<int> c2;
+ TEST_LIBCPP_ASSERT_FAILURE(c1.insert(c2.cbegin(), 5, 1),
+ "list::insert(iterator, n, x) called with an iterator not referring to this list");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+// 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**) {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ int i = 4;
+ TEST_LIBCPP_ASSERT_FAILURE(v1.insert(v2.begin(), i),
+ "list::insert(iterator, x) called with an iterator not referring to this list");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class... Args> void emplace(const_iterator p, Args&&... args);
-
-// UNSUPPORTED: c++03
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <list>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-struct A {
- explicit A(int i, double d) {
- (void)i;
- (void)d;
- }
-};
-
-int main(int, char**)
-{
- std::list<A> c1;
- std::list<A> c2;
- TEST_LIBCPP_ASSERT_FAILURE(c1.emplace(c2.cbegin(), 2, 3.5),
- "list::emplace(iterator, args...) called with an iterator not referring to this list");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 position) with end()
-
-// 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>::const_iterator i = l1.end();
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "list::erase(iterator) called with a non-dereferenceable iterator");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 position) with 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);
- std::list<int>::const_iterator i = l2.begin();
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "list::erase(iterator) called with an iterator not referring to this list");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <InputIterator Iter>
-// iterator insert(const_iterator position, Iter first, Iter last);
-
-// 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**)
-{
- {
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// iterator insert(const_iterator position, value_type&& x);
-
-// 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**)
-{
- std::list<int> v1(3);
- std::list<int> v2(3);
- TEST_LIBCPP_ASSERT_FAILURE(v1.insert(v2.begin(), 4),
- "list::insert(iterator, x) called with an iterator not referring to this list");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// iterator insert(const_iterator position, size_type n, const value_type& x);
-
-// 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**)
-{
- std::list<int> c1(100);
- std::list<int> c2;
- TEST_LIBCPP_ASSERT_FAILURE(c1.insert(c2.cbegin(), 5, 1),
- "list::insert(iterator, n, x) called with an iterator not referring to this list");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// iterator insert(const_iterator position, const value_type& x);
-
-// 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**)
-{
- std::list<int> v1(3);
- std::list<int> v2(3);
- int i = 4;
- TEST_LIBCPP_ASSERT_FAILURE(v1.insert(v2.begin(), i),
- "list::insert(iterator, x) called with an iterator not referring to this list");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// void pop_back();
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <list>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**)
-{
- int a[] = {1, 2, 3};
- std::list<int> c(a, a+3);
- c.pop_back();
- assert(c == std::list<int>(a, a+2));
- c.pop_back();
- assert(c == std::list<int>(a, a+1));
- c.pop_back();
- assert(c.empty());
- TEST_LIBCPP_ASSERT_FAILURE(c.pop_back(), "list::pop_back() called on an empty list");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// void splice(const_iterator position, list& x);
-
-// 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**)
-{
- {
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
-
-// 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**)
-{
- {
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// void splice(const_iterator position, list& x, iterator first, iterator last);
-
-// 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**)
-{
- {
- 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;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// void splice(const_iterator position, list& x);
+
+// 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**) {
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
+
+// 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**) {
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// void splice(const_iterator position, list& x, iterator first, iterator last);
+
+// 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**) {
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <vector>
+
+#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> C;
+ const C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <vector>
+
+#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> C;
+ const C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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: 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;
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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: 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[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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// pop_back() more than the number of elements in a vector
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <vector>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ std::vector<int> v;
+ v.push_back(0);
+ v.pop_back();
+ TEST_LIBCPP_ASSERT_FAILURE(v.pop_back(), "vector::pop_back called on an empty vector");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 "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;
- TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 "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;
- TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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"
-
-int main(int, char**)
-{
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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"
-#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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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"
-#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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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"
-#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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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"
-#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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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"
-#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");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <vector>
+
+#include "check_assertion.h"
+#include "min_allocator.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");
+ }
+
+ {
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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, 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.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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <vector>
+
+#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.end();
+ TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator");
+ }
+
+ {
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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, 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;
+ assert(i == c.end());
+ TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
+ }
+
+ {
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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, 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();
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <vector>
+
+#include "check_assertion.h"
+#include "min_allocator.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");
+ }
+
+ {
+ 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;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// pop_back() more than the number of elements in a vector
-
-// 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**) {
- std::vector<int> v;
- v.push_back(0);
- v.pop_back();
- TEST_LIBCPP_ASSERT_FAILURE(v.pop_back(), "vector::pop_back called on an empty vector");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// size_type bucket(const key_type& __k) const;
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <unordered_map>
+#include <string>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.bucket(3), "unordered container::bucket(key) called when bucket_count() == 0");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket_size(size_type n) const
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <unordered_map>
+#include <string>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.bucket_size(3), "unordered container::bucket_size(n) called with n >= bucket_count()");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <unordered_map>
+#include <string>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.max_load_factor(0), "unordered container::max_load_factor(lf) called with lf <= 0");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
-// class Alloc = allocator<pair<const Key, T>>>
-// class unordered_map
-
-// size_type bucket_size(size_type n) const
-
-// 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;
- TEST_LIBCPP_ASSERT_FAILURE(c.bucket_size(3), "unordered container::bucket_size(n) called with n >= bucket_count()");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// size_type bucket(const key_type& __k) const;
-
-// 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;
- TEST_LIBCPP_ASSERT_FAILURE(c.bucket(3), "unordered container::bucket(key) called when bucket_count() == 0");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// iterator insert(const_iterator p, const value_type& x);
-
-// 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::unordered_map<double, int> C;
- typedef C::value_type P;
- C c;
- C c2;
- C::const_iterator e = c2.end();
- P v(3.5, 3);
-#if TEST_STD_VER < 11
- TEST_LIBCPP_ASSERT_FAILURE(
- c.insert(e, v),
- "unordered_map::insert(const_iterator, const value_type&) called with an iterator not referring to this unordered_map");
-#else
- TEST_LIBCPP_ASSERT_FAILURE(
- c.insert(e, v),
- "unordered_map::insert(const_iterator, value_type&&) called with an iterator not referring to this unordered_map");
-#endif
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// <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
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_map>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::unordered_map<double, int> C;
- typedef C::value_type P;
- C c;
- C c2;
- C::const_iterator e = c2.end();
- TEST_LIBCPP_ASSERT_FAILURE(
- c.insert(e, P(3.5, 3)),
- "unordered_map::insert(const_iterator, const value_type&) called with an iterator not referring to this unordered_map");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Key, class Value, class Hash = hash<Key>, class Pred = equal_to<Key>,
-// class Alloc = allocator<pair<const Key, Value>>>
-// class unordered_map
-
-// void swap(unordered_map& x, unordered_map& y);
-
-// 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(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)};
- std::unordered_map<int, int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
- std::unordered_map<int, int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
- std::unordered_map<int, int>::iterator i1 = c1.begin();
- std::unordered_map<int, int>::iterator i2 = c2.begin();
- swap(c1, c2);
- c1.erase(i2);
- TEST_LIBCPP_ASSERT_FAILURE(
- c1.erase(i1), "unordered container erase(iterator) called with an iterator not referring to this container");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// iterator insert(const_iterator p, const value_type& x);
+
+// 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"
+
+int main(int, char**) {
+ typedef std::unordered_map<double, int> C;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5, 3);
+#if TEST_STD_VER < 11
+ TEST_LIBCPP_ASSERT_FAILURE(
+ c.insert(e, v),
+ "unordered_map::insert(const_iterator, const value_type&) called with an iterator not referring to this unordered_map");
+#else
+ TEST_LIBCPP_ASSERT_FAILURE(
+ c.insert(e, v),
+ "unordered_map::insert(const_iterator, value_type&&) called with an iterator not referring to this unordered_map");
+#endif
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// 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, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <unordered_map>
+
+#include "check_assertion.h"
+#include "test_macros.h"
+
+int main(int, char**) {
+ typedef std::unordered_map<double, int> C;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ TEST_LIBCPP_ASSERT_FAILURE(
+ c.insert(e, P(3.5, 3)),
+ "unordered_map::insert(const_iterator, const value_type&) called with an iterator not referring to this unordered_map");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Key, class Value, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, Value>>>
+// class unordered_map
+
+// void swap(unordered_map& x, unordered_map& y);
+
+// 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**) {
+ 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)};
+ std::unordered_map<int, int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_map<int, int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_map<int, int>::iterator i1 = c1.begin();
+ std::unordered_map<int, int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ TEST_LIBCPP_ASSERT_FAILURE(
+ c1.erase(i1), "unordered container erase(iterator) called with an iterator not referring to this container");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
-// class Alloc = allocator<pair<const Key, T>>>
-// class unordered_map
-
-// float max_load_factor() const;
-// void max_load_factor(float mlf);
-
-// 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;
- TEST_LIBCPP_ASSERT_FAILURE(c.max_load_factor(0), "unordered container::max_load_factor(lf) called with lf <= 0");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket(const key_type& __k) const;
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <unordered_map>
+#include <string>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.bucket(3), "unordered container::bucket(key) called when bucket_count() == 0");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket_size(size_type n) const
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <unordered_map>
+#include <string>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.bucket_size(3), "unordered container::bucket_size(n) called with n >= bucket_count()");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <unordered_map>
+#include <string>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.max_load_factor(0), "unordered container::max_load_factor(lf) called with lf <= 0");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
-// class Alloc = allocator<pair<const Key, T>>>
-// class unordered_multimap
-
-// size_type bucket(const key_type& __k) const;
-
-// 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;
- TEST_LIBCPP_ASSERT_FAILURE(c.bucket(3), "unordered container::bucket(key) called when bucket_count() == 0");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
-// class Alloc = allocator<pair<const Key, T>>>
-// class unordered_multimap
-
-// size_type bucket_size(size_type n) const
-
-// 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;
- TEST_LIBCPP_ASSERT_FAILURE(c.bucket_size(3), "unordered container::bucket_size(n) called with n >= bucket_count()");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// iterator insert(const_iterator p, const value_type& x);
-
-// 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::unordered_multimap<double, int> C;
- typedef C::value_type P;
- C c;
- C c2;
- C::const_iterator e = c2.end();
- P v(3.5, 3);
- TEST_LIBCPP_ASSERT_FAILURE(
- c.insert(e, v),
- "unordered container::emplace_hint(const_iterator, args...) called with an iterator not referring to this unordered container");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// <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
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_map>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::unordered_multimap<double, int> C;
- typedef C::value_type P;
- C c;
- C c2;
- C::const_iterator e = c2.end();
- TEST_LIBCPP_ASSERT_FAILURE(
- c.insert(e, P(3.5, 3)),
- "unordered container::emplace_hint(const_iterator, args...) called with an iterator not referring to this unordered container");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 <cassert>
-#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.begin();
- ++i;
- assert(i == c.end());
- TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container iterator");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Key, class Value, class Hash = hash<Key>, class Pred = equal_to<Key>,
-// class Alloc = allocator<pair<const Key, Value>>>
-// class unordered_multimap
-
-// void swap(unordered_multimap& x, unordered_multimap& y);
-
-// 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(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)};
- std::unordered_multimap<int, int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
- std::unordered_multimap<int, int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
- std::unordered_multimap<int, int>::iterator i1 = c1.begin();
- std::unordered_multimap<int, int>::iterator i2 = c2.begin();
- swap(c1, c2);
- c1.erase(i2);
- TEST_LIBCPP_ASSERT_FAILURE(
- c1.erase(i1), "unordered container erase(iterator) called with an iterator not referring to this container");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// iterator insert(const_iterator p, const value_type& x);
+
+// 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**) {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5, 3);
+ TEST_LIBCPP_ASSERT_FAILURE(
+ c.insert(e, v),
+ "unordered container::emplace_hint(const_iterator, args...) called with an iterator not referring to this unordered container");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// 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, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <unordered_map>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ TEST_LIBCPP_ASSERT_FAILURE(
+ c.insert(e, P(3.5, 3)),
+ "unordered container::emplace_hint(const_iterator, args...) called with an iterator not referring to this unordered container");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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_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");
+ }
+
+ {
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Key, class Value, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, Value>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& x, unordered_multimap& y);
+
+// 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**) {
+ 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)};
+ std::unordered_multimap<int, int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_multimap<int, int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_multimap<int, int>::iterator i1 = c1.begin();
+ std::unordered_multimap<int, int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ TEST_LIBCPP_ASSERT_FAILURE(
+ c1.erase(i1), "unordered container erase(iterator) called with an iterator not referring to this container");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
-// class Alloc = allocator<pair<const Key, T>>>
-// class unordered_multimap
-
-// float max_load_factor() const;
-// void max_load_factor(float mlf);
-
-// 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;
- TEST_LIBCPP_ASSERT_FAILURE(c.max_load_factor(0), "unordered container::max_load_factor(lf) called with lf <= 0");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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_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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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_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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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_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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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_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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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_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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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_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;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket(const key_type& __k) const;
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <unordered_set>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_multiset<int> C;
+ C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.bucket(3), "unordered container::bucket(key) called when bucket_count() == 0");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket_size(size_type n) const
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <unordered_set>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_multiset<int> C;
+ C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.bucket_size(3), "unordered container::bucket_size(n) called with n >= bucket_count()");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <unordered_set>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_multiset<int> C;
+ C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.max_load_factor(0), "unordered container::max_load_factor(lf) called with lf <= 0");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
-// class Alloc = allocator<Value>>
-// class unordered_multiset
-
-// size_type bucket(const key_type& __k) const;
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::unordered_multiset<int> C;
- C c;
- TEST_LIBCPP_ASSERT_FAILURE(c.bucket(3), "unordered container::bucket(key) called when bucket_count() == 0");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
-// class Alloc = allocator<Value>>
-// class unordered_multiset
-
-// size_type bucket_size(size_type n) const
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::unordered_multiset<int> C;
- C c;
- TEST_LIBCPP_ASSERT_FAILURE(c.bucket_size(3), "unordered container::bucket_size(n) called with n >= bucket_count()");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// iterator insert(const_iterator p, const value_type& x);
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::unordered_multiset<double> C;
- typedef C::value_type P;
- C c;
- C c2;
- C::const_iterator e = c2.end();
- P v(3.5);
- TEST_LIBCPP_ASSERT_FAILURE(
- c.insert(e, v),
- "unordered container::emplace_hint(const_iterator, args...) called with an iterator not referring to this unordered container");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-// UNSUPPORTED: c++03
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-// UNSUPPORTED: c++03
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-// UNSUPPORTED: c++03
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-// UNSUPPORTED: c++03
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
-// class Alloc = allocator<Value>>
-// class unordered_multiset
-
-// void swap(unordered_multiset& x, unordered_multiset& y);
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- int a1[] = {1, 3, 7, 9, 10};
- int a2[] = {0, 2, 4, 5, 6, 8, 11};
- std::unordered_multiset<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
- std::unordered_multiset<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
- std::unordered_multiset<int>::iterator i1 = c1.begin();
- std::unordered_multiset<int>::iterator i2 = c2.begin();
- swap(c1, c2);
- c1.erase(i2);
- TEST_LIBCPP_ASSERT_FAILURE(
- c1.erase(i1), "unordered container erase(iterator) called with an iterator not referring to this container");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// iterator insert(const_iterator p, const value_type& x);
+
+// 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**) {
+ typedef std::unordered_multiset<double> C;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5);
+ TEST_LIBCPP_ASSERT_FAILURE(
+ c.insert(e, v),
+ "unordered container::emplace_hint(const_iterator, args...) called with an iterator not referring to this unordered container");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void swap(unordered_multiset& x, unordered_multiset& y);
+
+// 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**) {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::unordered_multiset<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_multiset<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_multiset<int>::iterator i1 = c1.begin();
+ std::unordered_multiset<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ TEST_LIBCPP_ASSERT_FAILURE(
+ c1.erase(i1), "unordered container erase(iterator) called with an iterator not referring to this container");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 end()
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- 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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 iterator from another container
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- 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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 second iterator from another container
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- 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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 both iterators from another container
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- 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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 a bad range
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
-// class Alloc = allocator<Value>>
-// class unordered_multiset
-
-// float max_load_factor() const;
-// void max_load_factor(float mlf);
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::unordered_multiset<int> C;
- C c;
- TEST_LIBCPP_ASSERT_FAILURE(c.max_load_factor(0), "unordered container::max_load_factor(lf) called with lf <= 0");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket(const key_type& __k) const;
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <unordered_set>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_set<int> C;
+ C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.bucket(3), "unordered container::bucket(key) called when bucket_count() == 0");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket_size(size_type n) const
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <unordered_set>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_set<int> C;
+ C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.bucket_size(3), "unordered container::bucket_size(n) called with n >= bucket_count()");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <unordered_set>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::unordered_set<int> C;
+ C c;
+ TEST_LIBCPP_ASSERT_FAILURE(c.max_load_factor(-0.5f),
+ "unordered container::max_load_factor(lf) called with lf <= 0");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
-// class Alloc = allocator<Value>>
-// class unordered_set
-
-// size_type bucket(const key_type& __k) const;
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::unordered_set<int> C;
- C c;
- TEST_LIBCPP_ASSERT_FAILURE(c.bucket(3), "unordered container::bucket(key) called when bucket_count() == 0");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
-// class Alloc = allocator<Value>>
-// class unordered_set
-
-// size_type bucket_size(size_type n) const
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::unordered_set<int> C;
- C c;
- TEST_LIBCPP_ASSERT_FAILURE(c.bucket_size(3), "unordered container::bucket_size(n) called with n >= bucket_count()");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// iterator insert(const_iterator p, const value_type& x);
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::unordered_set<double> C;
- typedef C::value_type P;
- C c;
- C c2;
- C::const_iterator e = c2.end();
- P v(3.5);
- TEST_LIBCPP_ASSERT_FAILURE(
- c.insert(e, v),
- "unordered_set::insert(const_iterator, const value_type&) called with an iterator not referring to this unordered_set");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-// UNSUPPORTED: c++03
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.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(1);
- C::iterator i = c.end();
- TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container const_iterator");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-// UNSUPPORTED: c++03
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.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});
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-// UNSUPPORTED: c++03
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.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(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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-// UNSUPPORTED: c++03
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.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});
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
-// class Alloc = allocator<Value>>
-// class unordered_set
-
-// void swap(unordered_set& x, unordered_set& y);
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- int a1[] = {1, 3, 7, 9, 10};
- int a2[] = {0, 2, 4, 5, 6, 8, 11};
- std::unordered_set<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
- std::unordered_set<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
- std::unordered_set<int>::iterator i1 = c1.begin();
- std::unordered_set<int>::iterator i2 = c2.begin();
- swap(c1, c2);
- c1.erase(i2);
- TEST_LIBCPP_ASSERT_FAILURE(
- c1.erase(i1), "unordered container erase(iterator) called with an iterator not referring to this container");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// iterator insert(const_iterator p, const value_type& x);
+
+// 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**) {
+ typedef std::unordered_set<double> C;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5);
+ TEST_LIBCPP_ASSERT_FAILURE(
+ c.insert(e, v),
+ "unordered_set::insert(const_iterator, const value_type&) called with an iterator not referring to this unordered_set");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void swap(unordered_set& x, unordered_set& y);
+
+// 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**) {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::unordered_set<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_set<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_set<int>::iterator i1 = c1.begin();
+ std::unordered_set<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ TEST_LIBCPP_ASSERT_FAILURE(
+ c1.erase(i1), "unordered container erase(iterator) called with an iterator not referring to this container");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 end()
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- 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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 iterator from another container
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- 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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 second iterator from another container
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- 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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 both iterators from another container
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- 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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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 a bad range
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
-// class Alloc = allocator<Value>>
-// class unordered_set
-
-// float max_load_factor() const;
-// void max_load_factor(float mlf);
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <unordered_set>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::unordered_set<int> C;
- C c;
- TEST_LIBCPP_ASSERT_FAILURE(c.max_load_factor(-0.5f),
- "unordered container::max_load_factor(lf) called with lf <= 0");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <__debug>
+#include <cstdio>
+
+#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) {
+ DeathTest DT(Matcher);
+ DeathTest::ResultKind RK = DT.Run(func);
+ auto OnFailure = [&](std::string msg) {
+ std::fprintf(stderr, "EXPECT_DEATH( %s ) failed! (%s)\n\n", stmt, msg.c_str());
+ if (!DT.getChildStdErr().empty()) {
+ std::fprintf(stderr, "---------- standard err ----------\n%s\n", DT.getChildStdErr().c_str());
+ }
+ if (!DT.getChildStdOut().empty()) {
+ std::fprintf(stderr, "---------- standard out ----------\n%s\n", DT.getChildStdOut().c_str());
+ }
+ return false;
+ };
+ if (RK != ExpectResult)
+ return OnFailure(std::string("expected result did not occur: expected ") + DeathTest::ResultKindToString(ExpectResult) + " got: " + DeathTest::ResultKindToString(RK));
+ return true;
+}
+#define TEST_DEATH_TEST(RK, ...) assert((TestDeathTest(#__VA_ARGS__, [&]() { __VA_ARGS__; }, RK, AnyMatcher )))
+
+#define TEST_DEATH_TEST_MATCHES(RK, Matcher, ...) assert((TestDeathTest(#__VA_ARGS__, [&]() { __VA_ARGS__; }, RK, Matcher)))
+
+void my_libcpp_assert() {
+ _LIBCPP_ASSERT(false, "other");
+}
+
+void test_no_match_found() {
+ DebugInfoMatcher ExpectMatch("my message");
+ TEST_DEATH_TEST_MATCHES(DeathTest::RK_MatchFailure, ExpectMatch, my_libcpp_assert());
+}
+
+void test_did_not_die() {
+ TEST_DEATH_TEST(DeathTest::RK_DidNotDie, ((void)0));
+}
+
+void test_unknown() {
+ TEST_DEATH_TEST(DeathTest::RK_Unknown, std::exit(13));
+}
+
+int main(int, char**) {
+ test_no_match_found();
+ test_did_not_die();
+ test_unknown();
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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++11, c++14
+// UNSUPPORTED: libcpp-has-no-threads
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+// test multithreaded container debugging
+
+#include <cassert>
+#include <cstddef>
+#include <deque>
+#include <list>
+#include <thread>
+#include <vector>
+
+template <typename Container>
+Container makeContainer(int size) {
+ Container c;
+ typedef typename Container::value_type ValueType;
+ for (int i = 0; i < size; ++i)
+ c.insert(c.end(), ValueType(i));
+ assert(c.size() == static_cast<std::size_t>(size));
+ return c;
+}
+
+template <typename Container>
+void ThreadUseIter() {
+ const size_t maxRounds = 7;
+ struct TestRunner{
+ void operator()() {
+ for (size_t count = 0; count < maxRounds; count++) {
+ const size_t containerCount = 11;
+ std::vector<Container> containers;
+ std::vector<typename Container::iterator> iterators;
+ for (size_t containerIndex = 0; containerIndex < containerCount; containerIndex++) {
+ containers.push_back(makeContainer<Container>(3));
+ Container& c = containers.back();
+ iterators.push_back(c.begin());
+ iterators.push_back(c.end());
+ }
+ }
+ }
+ };
+
+ TestRunner r;
+ const size_t threadCount = 4;
+ std::vector<std::thread> threads;
+ for (size_t count = 0; count < threadCount; count++)
+ threads.emplace_back(r);
+ r();
+ for (size_t count = 0; count < threadCount; count++)
+ threads[count].join();
+}
+
+int main(int, char**) {
+ ThreadUseIter<std::vector<int> >();
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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++11, c++14
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+// test container debugging
+
+#include <map>
+#include <set>
+#include <utility>
+#include <cassert>
+#include "check_assertion.h"
+#include "container_debug_tests.h"
+#include "test_macros.h"
+
+using namespace IteratorDebugChecks;
+
+template <class Container, ContainerType CT>
+struct AssociativeContainerChecks : BasicContainerChecks<Container, CT> {
+ using Base = BasicContainerChecks<Container, CT>;
+ using value_type = typename Container::value_type;
+ using iterator = typename Container::iterator;
+ using const_iterator = typename Container::const_iterator;
+ using traits = std::iterator_traits<iterator>;
+ using category = typename traits::iterator_category;
+
+ using Base::makeContainer;
+public:
+ static void run() {
+ Base::run();
+ }
+
+private:
+ // FIXME Add tests here
+};
+
+int main(int, char**)
+{
+ using SetAlloc = test_allocator<int>;
+ using MapAlloc = test_allocator<std::pair<const int, int>>;
+ // FIXME: Add debug mode to these containers
+ if ((false)) {
+ AssociativeContainerChecks<
+ std::set<int, std::less<int>, SetAlloc>, CT_Set>::run();
+ AssociativeContainerChecks<
+ std::multiset<int, std::less<int>, SetAlloc>, CT_MultiSet>::run();
+ AssociativeContainerChecks<
+ std::map<int, int, std::less<int>, MapAlloc>, CT_Map>::run();
+ AssociativeContainerChecks<
+ std::multimap<int, int, std::less<int>, MapAlloc>, CT_MultiMap>::run();
+ }
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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, c++11, c++14
-// UNSUPPORTED: 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 "container_debug_tests.h"
-#include "test_macros.h"
-#include "debug_mode_helper.h"
-
-using namespace IteratorDebugChecks;
-
-template <class Container, ContainerType CT>
-struct AssociativeContainerChecks : BasicContainerChecks<Container, CT> {
- using Base = BasicContainerChecks<Container, CT>;
- using value_type = typename Container::value_type;
- using iterator = typename Container::iterator;
- using const_iterator = typename Container::const_iterator;
- using traits = std::iterator_traits<iterator>;
- using category = typename traits::iterator_category;
-
- using Base::makeContainer;
-public:
- static void run() {
- Base::run();
- }
-
-private:
- // FIXME Add tests here
-};
-
-int main(int, char**)
-{
- using SetAlloc = test_allocator<int>;
- using MapAlloc = test_allocator<std::pair<const int, int>>;
- // FIXME: Add debug mode to these containers
- if ((false)) {
- AssociativeContainerChecks<
- std::set<int, std::less<int>, SetAlloc>, CT_Set>::run();
- AssociativeContainerChecks<
- std::multiset<int, std::less<int>, SetAlloc>, CT_MultiSet>::run();
- AssociativeContainerChecks<
- std::map<int, int, std::less<int>, MapAlloc>, CT_Map>::run();
- AssociativeContainerChecks<
- std::multimap<int, int, std::less<int>, MapAlloc>, CT_MultiMap>::run();
- }
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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, c++11, c++14
-// UNSUPPORTED: windows
-// UNSUPPORTED: libcpp-has-no-threads
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// test multihtreaded 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) {
- Container c;
- typedef typename Container::value_type ValueType;
- for (int i = 0; i < size; ++i)
- c.insert(c.end(), ValueType(i));
- assert(c.size() == static_cast<std::size_t>(size));
- return c;
-}
-
-template <typename Container>
-void ThreadUseIter() {
- const size_t maxRounds = 7;
- struct TestRunner{
- void operator()() {
- for (size_t count = 0; count < maxRounds; count++) {
- const size_t containerCount = 11;
- std::vector<Container> containers;
- std::vector<typename Container::iterator> iterators;
- for (size_t containerIndex = 0; containerIndex < containerCount; containerIndex++) {
- containers.push_back(makeContainer<Container>(3));
- Container& c = containers.back();
- iterators.push_back(c.begin());
- iterators.push_back(c.end());
- }
- }
- }
- };
-
- TestRunner r;
- const size_t threadCount = 4;
- std::vector<std::thread> threads;
- for (size_t count = 0; count < threadCount; count++)
- threads.emplace_back(r);
- r();
- for (size_t count = 0; count < threadCount; count++)
- threads[count].join();
-}
-
-int main(int, char**) {
- ThreadUseIter<std::vector<int> >();
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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, c++11, c++14
-// UNSUPPORTED: 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 "container_debug_tests.h"
-#include "test_macros.h"
-#include "debug_mode_helper.h"
-
-using namespace IteratorDebugChecks;
-
-template <class Container, ContainerType CT>
-struct SequenceContainerChecks : BasicContainerChecks<Container, CT> {
- using Base = BasicContainerChecks<Container, CT>;
- using value_type = typename Container::value_type;
- using allocator_type = typename Container::allocator_type;
- using iterator = typename Container::iterator;
- using const_iterator = typename Container::const_iterator;
-
- using Base::makeContainer;
- using Base::makeValueType;
-public:
- static void run() {
- Base::run();
- SanityTest();
- FrontOnEmptyContainer();
-
- if constexpr(CT != CT_ForwardList) {
- AssignInvalidates();
- BackOnEmptyContainer();
- InsertIterValue();
- InsertIterSizeValue();
- InsertIterIterIter();
- EmplaceIterValue();
- EraseIterIter();
- }
- else {
- SpliceFirstElemAfter();
- }
- if constexpr (CT == CT_Vector || CT == CT_Deque || CT == CT_List) {
- PopBack();
- }
- if constexpr (CT == CT_List || CT == CT_Deque) {
- PopFront(); // FIXME: Run with forward list as well
- }
- if constexpr (CT == CT_List || CT == CT_ForwardList) {
- RemoveFirstElem();
- }
- if constexpr (CT == CT_List) {
- SpliceFirstElem();
- SpliceSameContainer();
- }
- }
-
-private:
- static void SanityTest() {
- // sanity test
- Container C = {1, 1, 1, 1};
- ::DoNotOptimize(&C);
- }
-
- static void RemoveFirstElem() {
- // See llvm.org/PR35564
- // remove(<first-elem>)
- {
- Container C = makeContainer(1);
- auto FirstVal = *(C.begin());
- C.remove(FirstVal);
- assert(C.empty());
- }
- {
- Container C = {1, 1, 1, 1};
- auto FirstVal = *(C.begin());
- C.remove(FirstVal);
- assert(C.empty());
- }
- }
-
- static void SpliceFirstElem() {
- // See llvm.org/PR35564
- // splice(<first-elem>)
- {
- Container C = makeContainer(1);
- Container C2;
- C2.splice(C2.end(), C, C.begin(), ++C.begin());
- }
- {
- Container C = makeContainer(1);
- Container C2;
- C2.splice(C2.end(), C, C.begin());
- }
- }
-
- static void SpliceSameContainer() {
- // splice(<same-container>)
- Container C = {1, 1};
- C.splice(C.end(), C, C.begin());
- }
-
- static void SpliceFirstElemAfter() {
- // See llvm.org/PR35564
- // splice(<first-elem>)
- {
- Container C = makeContainer(1);
- Container C2;
- C2.splice_after(C2.begin(), C, C.begin(), ++C.begin());
- }
- {
- Container C = makeContainer(1);
- Container C2;
- C2.splice_after(C2.begin(), C, C.begin());
- }
- }
-
- static void AssignInvalidates() {
- // assign(Size, Value)
- Container C(allocator_type{});
- iterator it1, it2, it3;
- auto reset = [&]() {
- C = makeContainer(3);
- it1 = C.begin();
- it2 = ++C.begin();
- it3 = C.end();
- };
- auto check = [&]() {
- EXPECT_DEATH( C.erase(it1) );
- EXPECT_DEATH( C.erase(it2) );
- EXPECT_DEATH( C.erase(it3, C.end()) );
- };
- reset();
- C.assign(2, makeValueType(4));
- check();
- reset();
- // assign(Iter, Iter)
- std::vector<value_type> V = {
- makeValueType(1),
- makeValueType(2),
- makeValueType(3)
- };
- C.assign(V.begin(), V.end());
- check();
- reset();
- // assign(initializer_list)
- C.assign({makeValueType(1), makeValueType(2), makeValueType(3)});
- check();
- }
-
- static void BackOnEmptyContainer() {
- // testing back on empty
- Container C = makeContainer(1);
- Container const& CC = C;
- (void)C.back();
- (void)CC.back();
- C.clear();
- EXPECT_DEATH( C.back() );
- EXPECT_DEATH( CC.back() );
- }
-
- static void FrontOnEmptyContainer() {
- // testing front on empty
- Container C = makeContainer(1);
- Container const& CC = C;
- (void)C.front();
- (void)CC.front();
- C.clear();
- EXPECT_DEATH( C.front() );
- EXPECT_DEATH( CC.front() );
- }
-
- static void EraseIterIter() {
- // testing erase iter iter invalidation
- Container C1 = makeContainer(3);
- iterator it1 = C1.begin();
- iterator it1_next = ++C1.begin();
- iterator it1_after_next = ++C1.begin();
- ++it1_after_next;
- iterator it1_back = --C1.end();
- assert(it1_next != it1_back);
- if (CT == CT_Vector) {
- EXPECT_DEATH( C1.erase(it1_next, it1) ); // bad range
- }
- C1.erase(it1, it1_after_next);
- EXPECT_DEATH( C1.erase(it1) );
- EXPECT_DEATH( C1.erase(it1_next) );
- if (CT == CT_List) {
- C1.erase(it1_back);
- } else {
- EXPECT_DEATH( C1.erase(it1_back) );
- }
- }
-
- static void PopBack() {
- // testing pop_back() invalidation
- Container C1 = makeContainer(2);
- iterator it1 = C1.end();
- --it1;
- C1.pop_back();
- EXPECT_DEATH( C1.erase(it1) );
- C1.erase(C1.begin());
- assert(C1.size() == 0);
- EXPECT_DEATH( C1.pop_back() );
- }
-
- static void PopFront() {
- // testing pop_front() invalidation
- Container C1 = makeContainer(2);
- iterator it1 = C1.begin();
- C1.pop_front();
- EXPECT_DEATH( C1.erase(it1) );
- C1.erase(C1.begin());
- assert(C1.size() == 0);
- EXPECT_DEATH( C1.pop_front() );
- }
-
- static void InsertIterValue() {
- // testing insert(iter, value)
- Container C1 = makeContainer(2);
- iterator it1 = C1.begin();
- iterator it1_next = it1;
- ++it1_next;
- Container C2 = C1;
- const value_type value = makeValueType(3);
- value_type rvalue = makeValueType(3);
- EXPECT_DEATH( C2.insert(it1, value) ); // wrong container
- EXPECT_DEATH( C2.insert(it1, std::move(rvalue)) ); // wrong container
- C1.insert(it1_next, value);
- if (CT == CT_List) {
- C1.insert(it1_next, value);
- C1.insert(it1, value);
- C1.insert(it1_next, std::move(rvalue));
- C1.insert(it1, std::move(rvalue));
- } else {
- EXPECT_DEATH( C1.insert(it1_next, value) ); // invalidated iterator
- EXPECT_DEATH( C1.insert(it1, value) ); // invalidated iterator
- EXPECT_DEATH( C1.insert(it1_next, std::move(rvalue)) ); // invalidated iterator
- EXPECT_DEATH( C1.insert(it1, std::move(rvalue)) ); // invalidated iterator
- }
- }
-
- static void EmplaceIterValue() {
- // testing emplace(iter, value)
- Container C1 = makeContainer(2);
- iterator it1 = C1.begin();
- iterator it1_next = it1;
- ++it1_next;
- Container C2 = C1;
- const value_type value = makeValueType(3);
- EXPECT_DEATH( C2.emplace(it1, value) ); // wrong container
- EXPECT_DEATH( C2.emplace(it1, makeValueType(4)) ); // wrong container
- C1.emplace(it1_next, value);
- if (CT == CT_List) {
- C1.emplace(it1_next, value);
- C1.emplace(it1, value);
- } else {
- EXPECT_DEATH( C1.emplace(it1_next, value) ); // invalidated iterator
- EXPECT_DEATH( C1.emplace(it1, value) ); // invalidated iterator
- }
- }
-
- static void InsertIterSizeValue() {
- // testing insert(iter, size, value)
- Container C1 = makeContainer(2);
- iterator it1 = C1.begin();
- iterator it1_next = it1;
- ++it1_next;
- Container C2 = C1;
- const value_type value = makeValueType(3);
- EXPECT_DEATH( C2.insert(it1, 1, value) ); // wrong container
- C1.insert(it1_next, 2, value);
- if (CT == CT_List) {
- C1.insert(it1_next, 3, value);
- C1.insert(it1, 1, value);
- } else {
- EXPECT_DEATH( C1.insert(it1_next, 1, value) ); // invalidated iterator
- EXPECT_DEATH( C1.insert(it1, 1, value) ); // invalidated iterator
- }
- }
-
- static void InsertIterIterIter() {
- // testing insert(iter, iter, iter)
- Container C1 = makeContainer(2);
- iterator it1 = C1.begin();
- iterator it1_next = it1;
- ++it1_next;
- Container C2 = C1;
- std::vector<value_type> V = {
- makeValueType(1),
- makeValueType(2),
- makeValueType(3)
- };
- EXPECT_DEATH( C2.insert(it1, V.begin(), V.end()) ); // wrong container
- C1.insert(it1_next, V.begin(), V.end());
- if (CT == CT_List) {
- C1.insert(it1_next, V.begin(), V.end());
- C1.insert(it1, V.begin(), V.end());
- } else {
- EXPECT_DEATH( C1.insert(it1_next, V.begin(), V.end()) ); // invalidated iterator
- EXPECT_DEATH( C1.insert(it1, V.begin(), V.end()) ); // invalidated iterator
- }
- }
-};
-
-int main(int, char**)
-{
- using Alloc = test_allocator<int>;
- {
- SequenceContainerChecks<std::list<int, Alloc>, CT_List>::run();
- SequenceContainerChecks<std::vector<int, Alloc>, CT_Vector>::run();
- }
- // FIXME these containers don't support iterator debugging
- if ((false)) {
- SequenceContainerChecks<
- std::vector<bool, test_allocator<bool>>, CT_VectorBool>::run();
- SequenceContainerChecks<
- std::forward_list<int, Alloc>, CT_ForwardList>::run();
- SequenceContainerChecks<
- std::deque<int, Alloc>, CT_Deque>::run();
- }
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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, c++11, c++14
-// UNSUPPORTED: 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 "container_debug_tests.h"
-#include "debug_mode_helper.h"
-
-using namespace IteratorDebugChecks;
-
-typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> StringType;
-
-template <class Container = StringType, ContainerType CT = CT_String>
-struct StringContainerChecks : BasicContainerChecks<Container, CT> {
- using Base = BasicContainerChecks<Container, CT_String>;
- using value_type = typename Container::value_type;
- using allocator_type = typename Container::allocator_type;
- using iterator = typename Container::iterator;
- using const_iterator = typename Container::const_iterator;
-
- using Base::makeContainer;
- using Base::makeValueType;
-
-public:
- static void run() {
- Base::run_iterator_tests();
- Base::run_allocator_aware_tests();
-
- for (int N : {3, 128}) {
- FrontOnEmptyContainer(N);
- BackOnEmptyContainer(N);
- PopBack(N);
- }
- }
-
-private:
- static void BackOnEmptyContainer(int N) {
- // testing back on empty
- Container C = makeContainer(N);
- Container const& CC = C;
- iterator it = --C.end();
- (void)C.back();
- (void)CC.back();
- C.pop_back();
- EXPECT_DEATH( C.erase(it) );
- C.clear();
- EXPECT_DEATH( C.back() );
- EXPECT_DEATH( CC.back() );
- }
-
- static void FrontOnEmptyContainer(int N) {
- // testing front on empty
- Container C = makeContainer(N);
- Container const& CC = C;
- (void)C.front();
- (void)CC.front();
- C.clear();
- EXPECT_DEATH( C.front() );
- EXPECT_DEATH( CC.front() );
- }
-
- static void PopBack(int N) {
- // testing pop_back() invalidation
- Container C1 = makeContainer(N);
- iterator it1 = C1.end();
- --it1;
- C1.pop_back();
- EXPECT_DEATH( C1.erase(it1) );
- C1.erase(C1.begin(), C1.end());
- assert(C1.size() == 0);
- EXPECT_DEATH_MATCHES(DebugInfoMatcher("string::pop_back(): string is already empty"), C1.pop_back() );
- }
-};
-
-int main(int, char**)
-{
- StringContainerChecks<>::run();
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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, c++11, c++14
-// UNSUPPORTED: 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 "container_debug_tests.h"
-#include "test_macros.h"
-#include "debug_mode_helper.h"
-
-using namespace IteratorDebugChecks;
-
-template <class Container, ContainerType CT>
-struct UnorderedContainerChecks : BasicContainerChecks<Container, CT> {
- using Base = BasicContainerChecks<Container, CT>;
- using value_type = typename Container::value_type;
- using iterator = typename Container::iterator;
- using const_iterator = typename Container::const_iterator;
- using traits = std::iterator_traits<iterator>;
- using category = typename traits::iterator_category;
-
- using Base::makeContainer;
-public:
- static void run() {
- Base::run();
- }
-private:
-
-};
-
-int main(int, char**)
-{
- using SetAlloc = test_allocator<int>;
- using MapAlloc = test_allocator<std::pair<const int, int>>;
- {
- UnorderedContainerChecks<
- std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, MapAlloc>,
- CT_UnorderedMap>::run();
- UnorderedContainerChecks<
- std::unordered_set<int, std::hash<int>, std::equal_to<int>, SetAlloc>,
- CT_UnorderedSet>::run();
- UnorderedContainerChecks<
- std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>, MapAlloc>,
- CT_UnorderedMultiMap>::run();
- UnorderedContainerChecks<
- std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, SetAlloc>,
- CT_UnorderedMultiSet>::run();
- }
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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++11, c++14
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+// 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"
+
+using namespace IteratorDebugChecks;
+
+template <class Container, ContainerType CT>
+struct SequenceContainerChecks : BasicContainerChecks<Container, CT> {
+ using Base = BasicContainerChecks<Container, CT>;
+ using value_type = typename Container::value_type;
+ using allocator_type = typename Container::allocator_type;
+ using iterator = typename Container::iterator;
+ using const_iterator = typename Container::const_iterator;
+
+ using Base::makeContainer;
+ using Base::makeValueType;
+public:
+ static void run() {
+ Base::run();
+ SanityTest();
+ FrontOnEmptyContainer();
+
+ if constexpr(CT != CT_ForwardList) {
+ AssignInvalidates();
+ BackOnEmptyContainer();
+ InsertIterValue();
+ InsertIterSizeValue();
+ InsertIterIterIter();
+ EmplaceIterValue();
+ EraseIterIter();
+ }
+ else {
+ SpliceFirstElemAfter();
+ }
+ if constexpr (CT == CT_Vector || CT == CT_Deque || CT == CT_List) {
+ PopBack();
+ }
+ if constexpr (CT == CT_List || CT == CT_Deque) {
+ PopFront(); // FIXME: Run with forward list as well
+ }
+ if constexpr (CT == CT_List || CT == CT_ForwardList) {
+ RemoveFirstElem();
+ }
+ if constexpr (CT == CT_List) {
+ SpliceFirstElem();
+ SpliceSameContainer();
+ }
+ }
+
+private:
+ static void SanityTest() {
+ // sanity test
+ Container C = {1, 1, 1, 1};
+ ::DoNotOptimize(&C);
+ }
+
+ static void RemoveFirstElem() {
+ // See llvm.org/PR35564
+ // remove(<first-elem>)
+ {
+ Container C = makeContainer(1);
+ auto FirstVal = *(C.begin());
+ C.remove(FirstVal);
+ assert(C.empty());
+ }
+ {
+ Container C = {1, 1, 1, 1};
+ auto FirstVal = *(C.begin());
+ C.remove(FirstVal);
+ assert(C.empty());
+ }
+ }
+
+ static void SpliceFirstElem() {
+ // See llvm.org/PR35564
+ // splice(<first-elem>)
+ {
+ Container C = makeContainer(1);
+ Container C2;
+ C2.splice(C2.end(), C, C.begin(), ++C.begin());
+ }
+ {
+ Container C = makeContainer(1);
+ Container C2;
+ C2.splice(C2.end(), C, C.begin());
+ }
+ }
+
+ static void SpliceSameContainer() {
+ // splice(<same-container>)
+ Container C = {1, 1};
+ C.splice(C.end(), C, C.begin());
+ }
+
+ static void SpliceFirstElemAfter() {
+ // See llvm.org/PR35564
+ // splice(<first-elem>)
+ {
+ Container C = makeContainer(1);
+ Container C2;
+ C2.splice_after(C2.begin(), C, C.begin(), ++C.begin());
+ }
+ {
+ Container C = makeContainer(1);
+ Container C2;
+ C2.splice_after(C2.begin(), C, C.begin());
+ }
+ }
+
+ static void AssignInvalidates() {
+ // assign(Size, Value)
+ Container C(allocator_type{});
+ iterator it1, it2, it3;
+ auto reset = [&]() {
+ C = makeContainer(3);
+ it1 = C.begin();
+ it2 = ++C.begin();
+ it3 = C.end();
+ };
+ auto check = [&]() {
+ EXPECT_DEATH( C.erase(it1) );
+ EXPECT_DEATH( C.erase(it2) );
+ EXPECT_DEATH( C.erase(it3, C.end()) );
+ };
+ reset();
+ C.assign(2, makeValueType(4));
+ check();
+ reset();
+ // assign(Iter, Iter)
+ std::vector<value_type> V = {
+ makeValueType(1),
+ makeValueType(2),
+ makeValueType(3)
+ };
+ C.assign(V.begin(), V.end());
+ check();
+ reset();
+ // assign(initializer_list)
+ C.assign({makeValueType(1), makeValueType(2), makeValueType(3)});
+ check();
+ }
+
+ static void BackOnEmptyContainer() {
+ // testing back on empty
+ Container C = makeContainer(1);
+ Container const& CC = C;
+ (void)C.back();
+ (void)CC.back();
+ C.clear();
+ EXPECT_DEATH( C.back() );
+ EXPECT_DEATH( CC.back() );
+ }
+
+ static void FrontOnEmptyContainer() {
+ // testing front on empty
+ Container C = makeContainer(1);
+ Container const& CC = C;
+ (void)C.front();
+ (void)CC.front();
+ C.clear();
+ EXPECT_DEATH( C.front() );
+ EXPECT_DEATH( CC.front() );
+ }
+
+ static void EraseIterIter() {
+ // testing erase iter iter invalidation
+ Container C1 = makeContainer(3);
+ iterator it1 = C1.begin();
+ iterator it1_next = ++C1.begin();
+ iterator it1_after_next = ++C1.begin();
+ ++it1_after_next;
+ iterator it1_back = --C1.end();
+ assert(it1_next != it1_back);
+ if (CT == CT_Vector) {
+ EXPECT_DEATH( C1.erase(it1_next, it1) ); // bad range
+ }
+ C1.erase(it1, it1_after_next);
+ EXPECT_DEATH( C1.erase(it1) );
+ EXPECT_DEATH( C1.erase(it1_next) );
+ if (CT == CT_List) {
+ C1.erase(it1_back);
+ } else {
+ EXPECT_DEATH( C1.erase(it1_back) );
+ }
+ }
+
+ static void PopBack() {
+ // testing pop_back() invalidation
+ Container C1 = makeContainer(2);
+ iterator it1 = C1.end();
+ --it1;
+ C1.pop_back();
+ EXPECT_DEATH( C1.erase(it1) );
+ C1.erase(C1.begin());
+ assert(C1.size() == 0);
+ EXPECT_DEATH( C1.pop_back() );
+ }
+
+ static void PopFront() {
+ // testing pop_front() invalidation
+ Container C1 = makeContainer(2);
+ iterator it1 = C1.begin();
+ C1.pop_front();
+ EXPECT_DEATH( C1.erase(it1) );
+ C1.erase(C1.begin());
+ assert(C1.size() == 0);
+ EXPECT_DEATH( C1.pop_front() );
+ }
+
+ static void InsertIterValue() {
+ // testing insert(iter, value)
+ Container C1 = makeContainer(2);
+ iterator it1 = C1.begin();
+ iterator it1_next = it1;
+ ++it1_next;
+ Container C2 = C1;
+ const value_type value = makeValueType(3);
+ value_type rvalue = makeValueType(3);
+ EXPECT_DEATH( C2.insert(it1, value) ); // wrong container
+ EXPECT_DEATH( C2.insert(it1, std::move(rvalue)) ); // wrong container
+ C1.insert(it1_next, value);
+ if (CT == CT_List) {
+ C1.insert(it1_next, value);
+ C1.insert(it1, value);
+ C1.insert(it1_next, std::move(rvalue));
+ C1.insert(it1, std::move(rvalue));
+ } else {
+ EXPECT_DEATH( C1.insert(it1_next, value) ); // invalidated iterator
+ EXPECT_DEATH( C1.insert(it1, value) ); // invalidated iterator
+ EXPECT_DEATH( C1.insert(it1_next, std::move(rvalue)) ); // invalidated iterator
+ EXPECT_DEATH( C1.insert(it1, std::move(rvalue)) ); // invalidated iterator
+ }
+ }
+
+ static void EmplaceIterValue() {
+ // testing emplace(iter, value)
+ Container C1 = makeContainer(2);
+ iterator it1 = C1.begin();
+ iterator it1_next = it1;
+ ++it1_next;
+ Container C2 = C1;
+ const value_type value = makeValueType(3);
+ EXPECT_DEATH( C2.emplace(it1, value) ); // wrong container
+ EXPECT_DEATH( C2.emplace(it1, makeValueType(4)) ); // wrong container
+ C1.emplace(it1_next, value);
+ if (CT == CT_List) {
+ C1.emplace(it1_next, value);
+ C1.emplace(it1, value);
+ } else {
+ EXPECT_DEATH( C1.emplace(it1_next, value) ); // invalidated iterator
+ EXPECT_DEATH( C1.emplace(it1, value) ); // invalidated iterator
+ }
+ }
+
+ static void InsertIterSizeValue() {
+ // testing insert(iter, size, value)
+ Container C1 = makeContainer(2);
+ iterator it1 = C1.begin();
+ iterator it1_next = it1;
+ ++it1_next;
+ Container C2 = C1;
+ const value_type value = makeValueType(3);
+ EXPECT_DEATH( C2.insert(it1, 1, value) ); // wrong container
+ C1.insert(it1_next, 2, value);
+ if (CT == CT_List) {
+ C1.insert(it1_next, 3, value);
+ C1.insert(it1, 1, value);
+ } else {
+ EXPECT_DEATH( C1.insert(it1_next, 1, value) ); // invalidated iterator
+ EXPECT_DEATH( C1.insert(it1, 1, value) ); // invalidated iterator
+ }
+ }
+
+ static void InsertIterIterIter() {
+ // testing insert(iter, iter, iter)
+ Container C1 = makeContainer(2);
+ iterator it1 = C1.begin();
+ iterator it1_next = it1;
+ ++it1_next;
+ Container C2 = C1;
+ std::vector<value_type> V = {
+ makeValueType(1),
+ makeValueType(2),
+ makeValueType(3)
+ };
+ EXPECT_DEATH( C2.insert(it1, V.begin(), V.end()) ); // wrong container
+ C1.insert(it1_next, V.begin(), V.end());
+ if (CT == CT_List) {
+ C1.insert(it1_next, V.begin(), V.end());
+ C1.insert(it1, V.begin(), V.end());
+ } else {
+ EXPECT_DEATH( C1.insert(it1_next, V.begin(), V.end()) ); // invalidated iterator
+ EXPECT_DEATH( C1.insert(it1, V.begin(), V.end()) ); // invalidated iterator
+ }
+ }
+};
+
+int main(int, char**)
+{
+ using Alloc = test_allocator<int>;
+ {
+ SequenceContainerChecks<std::list<int, Alloc>, CT_List>::run();
+ SequenceContainerChecks<std::vector<int, Alloc>, CT_Vector>::run();
+ }
+ // FIXME these containers don't support iterator debugging
+ if ((false)) {
+ SequenceContainerChecks<
+ std::vector<bool, test_allocator<bool>>, CT_VectorBool>::run();
+ SequenceContainerChecks<
+ std::forward_list<int, Alloc>, CT_ForwardList>::run();
+ SequenceContainerChecks<
+ std::deque<int, Alloc>, CT_Deque>::run();
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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++11, c++14
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+// test container debugging
+
+#include <string>
+#include <vector>
+
+#include "test_macros.h"
+#include "check_assertion.h"
+#include "container_debug_tests.h"
+
+using namespace IteratorDebugChecks;
+
+typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> StringType;
+
+template <class Container = StringType, ContainerType CT = CT_String>
+struct StringContainerChecks : BasicContainerChecks<Container, CT> {
+ using Base = BasicContainerChecks<Container, CT_String>;
+ using value_type = typename Container::value_type;
+ using allocator_type = typename Container::allocator_type;
+ using iterator = typename Container::iterator;
+ using const_iterator = typename Container::const_iterator;
+
+ using Base::makeContainer;
+ using Base::makeValueType;
+
+public:
+ static void run() {
+ Base::run_iterator_tests();
+ Base::run_allocator_aware_tests();
+
+ for (int N : {3, 128}) {
+ FrontOnEmptyContainer(N);
+ BackOnEmptyContainer(N);
+ PopBack(N);
+ }
+ }
+
+private:
+ static void BackOnEmptyContainer(int N) {
+ // testing back on empty
+ Container C = makeContainer(N);
+ Container const& CC = C;
+ iterator it = --C.end();
+ (void)C.back();
+ (void)CC.back();
+ C.pop_back();
+ EXPECT_DEATH( C.erase(it) );
+ C.clear();
+ EXPECT_DEATH( C.back() );
+ EXPECT_DEATH( CC.back() );
+ }
+
+ static void FrontOnEmptyContainer(int N) {
+ // testing front on empty
+ Container C = makeContainer(N);
+ Container const& CC = C;
+ (void)C.front();
+ (void)CC.front();
+ C.clear();
+ EXPECT_DEATH( C.front() );
+ EXPECT_DEATH( CC.front() );
+ }
+
+ static void PopBack(int N) {
+ // testing pop_back() invalidation
+ Container C1 = makeContainer(N);
+ iterator it1 = C1.end();
+ --it1;
+ C1.pop_back();
+ EXPECT_DEATH( C1.erase(it1) );
+ C1.erase(C1.begin(), C1.end());
+ assert(C1.size() == 0);
+ EXPECT_DEATH_MATCHES(DebugInfoMatcher("string::pop_back(): string is already empty"), C1.pop_back() );
+ }
+};
+
+int main(int, char**)
+{
+ StringContainerChecks<>::run();
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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++11, c++14
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+// 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"
+
+using namespace IteratorDebugChecks;
+
+template <class Container, ContainerType CT>
+struct UnorderedContainerChecks : BasicContainerChecks<Container, CT> {
+ using Base = BasicContainerChecks<Container, CT>;
+ using value_type = typename Container::value_type;
+ using iterator = typename Container::iterator;
+ using const_iterator = typename Container::const_iterator;
+ using traits = std::iterator_traits<iterator>;
+ using category = typename traits::iterator_category;
+
+ using Base::makeContainer;
+public:
+ static void run() {
+ Base::run();
+ }
+private:
+
+};
+
+int main(int, char**)
+{
+ using SetAlloc = test_allocator<int>;
+ using MapAlloc = test_allocator<std::pair<const int, int>>;
+ {
+ UnorderedContainerChecks<
+ std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, MapAlloc>,
+ CT_UnorderedMap>::run();
+ UnorderedContainerChecks<
+ std::unordered_set<int, std::hash<int>, std::equal_to<int>, SetAlloc>,
+ CT_UnorderedSet>::run();
+ UnorderedContainerChecks<
+ std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>, MapAlloc>,
+ CT_UnorderedMultiMap>::run();
+ UnorderedContainerChecks<
+ std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, SetAlloc>,
+ CT_UnorderedMultiSet>::run();
+ }
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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, c++11, c++14
-// UNSUPPORTED: windows
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// test container debugging
-
-#include <string_view>
-
-#include "test_macros.h"
-#include "debug_mode_helper.h"
-
-void test_null_argument() {
- // C++2b prohibits construction of string_view from nullptr_t.
- const char* nullp = nullptr;
- const char* null = NULL;
- (void)nullp;
- (void)null;
- EXPECT_DEATH((std::string_view(nullp)));
- EXPECT_DEATH((std::string_view(null)));
- EXPECT_DEATH(std::string_view(static_cast<const char*>(0)));
- {
- std::string_view v;
- EXPECT_DEATH(((void)(v == nullp)));
- EXPECT_DEATH(((void)(nullp == v)));
- }
-}
-
-int main(int, char**) {
- test_null_argument();
-
- return 0;
-}
//
//===----------------------------------------------------------------------===//
-// 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.
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-#include <__debug>
-#include "debug_mode_helper.h"
-
-#include <cstdio>
-#include "test_macros.h"
-
-
-template <class Func>
-inline bool TestDeathTest(const char* stmt, Func&& func, DeathTest::ResultKind ExpectResult, DebugInfoMatcher Matcher = AnyMatcher) {
- DeathTest DT(Matcher);
- DeathTest::ResultKind RK = DT.Run(func);
- auto OnFailure = [&](std::string msg) {
- std::fprintf(stderr, "EXPECT_DEATH( %s ) failed! (%s)\n\n", stmt, msg.c_str());
- if (!DT.getChildStdErr().empty()) {
- std::fprintf(stderr, "---------- standard err ----------\n%s\n", DT.getChildStdErr().c_str());
- }
- if (!DT.getChildStdOut().empty()) {
- std::fprintf(stderr, "---------- standard out ----------\n%s\n", DT.getChildStdOut().c_str());
- }
- return false;
- };
- if (RK != ExpectResult)
- return OnFailure(std::string("expected result did not occur: expected ") + DeathTest::ResultKindToString(ExpectResult) + " got: " + DeathTest::ResultKindToString(RK));
- return true;
-}
-#define TEST_DEATH_TEST(RK, ...) assert((TestDeathTest(#__VA_ARGS__, [&]() { __VA_ARGS__; }, RK, AnyMatcher )))
-
-#define TEST_DEATH_TEST_MATCHES(RK, Matcher, ...) assert((TestDeathTest(#__VA_ARGS__, [&]() { __VA_ARGS__; }, RK, Matcher)))
-
-void my_libcpp_assert() {
- _LIBCPP_ASSERT(false, "other");
-}
-
-void test_no_match_found() {
- DebugInfoMatcher ExpectMatch("my message");
- TEST_DEATH_TEST_MATCHES(DeathTest::RK_MatchFailure, ExpectMatch, my_libcpp_assert());
-}
-
-void test_did_not_die() {
- TEST_DEATH_TEST(DeathTest::RK_DidNotDie, ((void)0));
-}
-
-void test_unknown() {
- TEST_DEATH_TEST(DeathTest::RK_Unknown, std::exit(13));
-}
-
-int main(int, char**)
-{
- test_no_match_found();
- test_did_not_die();
- test_unknown();
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-// UNSUPPORTED: libcxx-no-debug-mode
-
-#include <cstdlib>
-#include <string>
-#include <type_traits>
-#include <__debug>
-#include <cassert>
-
-#include "test_macros.h"
-
-void my_debug_function(std::__libcpp_debug_info const& info) {
- assert(info.__msg_ == std::string("foo"));
- std::exit(0);
-}
-
-int main(int, char**)
-{
- std::__libcpp_set_debug_function(&my_debug_function);
- _LIBCPP_ASSERT(false, "foo");
- return 1;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+// UNSUPPORTED: libcxx-no-debug-mode
+
+#include <cstdlib>
+#include <string>
+#include <type_traits>
+#include <__debug>
+#include <cassert>
+
+#include "test_macros.h"
+
+void my_debug_function(std::__libcpp_debug_info const& info) {
+ assert(info.__msg_ == std::string("foo"));
+ std::exit(0);
+}
+
+int main(int, char**)
+{
+ std::__libcpp_set_debug_function(&my_debug_function);
+ _LIBCPP_ASSERT(false, "foo");
+ return 1;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/memory_resource>
+
+// template <class T> class polymorphic_allocator
+
+// T* polymorphic_allocator<T>::deallocate(T*, size_t size)
+
+// 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"
+
+namespace ex = std::experimental::pmr;
+
+int main(int, char**) {
+ using Alloc = ex::polymorphic_allocator<int>;
+ using Traits = std::allocator_traits<Alloc>;
+ NullResource R;
+ Alloc a(&R);
+ const std::size_t maxSize = Traits::max_size(a);
+
+ a.deallocate(nullptr, maxSize); // no assertion
+ TEST_LIBCPP_ASSERT_FAILURE(a.deallocate(nullptr, maxSize + 1), "deallocate called for size which exceeds max_size()");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// <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
-
-#include <experimental/memory_resource>
-#include <type_traits>
-#include <cassert>
-
-#include "test_memory_resource.h"
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-namespace ex = std::experimental::pmr;
-
-int main(int, char**)
-{
- using Alloc = ex::polymorphic_allocator<int>;
- using Traits = std::allocator_traits<Alloc>;
- NullResource R;
- Alloc a(&R);
- const std::size_t maxSize = Traits::max_size(a);
-
- a.deallocate(nullptr, maxSize); // no assertion
- TEST_LIBCPP_ASSERT_FAILURE(a.deallocate(nullptr, maxSize + 1), "deallocate called for size which exceeds max_size()");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/memory_resource>
+
+// template <class T> class polymorphic_allocator
+
+// T* polymorphic_allocator<T>::deallocate(T*, size_t size)
+
+// 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"
+
+namespace ex = std::experimental::pmr;
+
+int main(int, char**) {
+ using Alloc = NullAllocator<char>;
+
+ AllocController P;
+ ex::resource_adaptor<Alloc> r(Alloc{P});
+ ex::memory_resource & m1 = r;
+
+ std::size_t maxSize = std::numeric_limits<std::size_t>::max()
+ - alignof(std::max_align_t);
+
+ m1.deallocate(nullptr, maxSize); // no assertion
+ TEST_LIBCPP_ASSERT_FAILURE(m1.deallocate(nullptr, maxSize + 1), "do_deallocate called for size which exceeds the maximum allocation size");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-
-// <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
-
-#include <experimental/memory_resource>
-#include <type_traits>
-#include <cassert>
-
-#include "test_memory_resource.h"
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-namespace ex = std::experimental::pmr;
-
-int main(int, char**)
-{
- using Alloc = NullAllocator<char>;
-
- AllocController P;
- ex::resource_adaptor<Alloc> r(Alloc{P});
- ex::memory_resource & m1 = r;
-
- std::size_t maxSize = std::numeric_limits<std::size_t>::max()
- - alignof(std::max_align_t);
-
- m1.deallocate(nullptr, maxSize); // no assertion
- TEST_LIBCPP_ASSERT_FAILURE(m1.deallocate(nullptr, maxSize + 1), "do_deallocate called for size which exceeds the maximum allocation size");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <filesystem>
+
+// class path
+
+#include "filesystem_include.h"
+#include <iterator>
+#include <type_traits>
+#include <cassert>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ // Test incrementing/decrementing a singular iterator
+ {
+ 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 incrementing the end iterator
+ {
+ fs::path p("foo/bar");
+ auto it = p.begin();
+ TEST_LIBCPP_ASSERT_FAILURE(--it, "attempting to decrement the begin iterator");
+ }
+
+ // Test incrementing the end iterator
+ {
+ fs::path p("foo/bar");
+ auto it = p.end();
+ TEST_LIBCPP_ASSERT_FAILURE(++it, "attempting to increment the end iterator");
+ }
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
-
-// <filesystem>
-
-// class path
-
-#include "filesystem_include.h"
-#include <iterator>
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_mode_helper.h"
-
-int main(int, char**) {
- using namespace fs;
- // Test incrementing/decrementing a singular iterator
- {
- path::iterator singular;
- EXPECT_DEATH( ++singular );
- EXPECT_DEATH( --singular );
- }
- // Test decrementing the begin iterator
- {
- path p("foo/bar");
- auto it = p.begin();
- ++it;
- ++it;
- EXPECT_DEATH( ++it );
- }
- // Test incrementing the end iterator
- {
- path p("foo/bar");
- auto it = p.end();
- EXPECT_DEATH( ++it );
- --it;
- --it;
- EXPECT_DEATH( --it );
- }
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// <list>
-
-// Call advance(non-bidi iterator, -1)
-
-#include <iterator>
-#include "test_macros.h"
-#include "debug_mode_helper.h"
-
-#include "test_iterators.h"
-
-int main(int, char**)
-{
- int a[] = {1, 2, 3};
-
- bidirectional_iterator<int *> bidi(a+1);
- std::advance(bidi, 1); // should work fine
- std::advance(bidi, 0); // should work fine
- std::advance(bidi, -1); // should work fine
-
- 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
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <list>
+
+// Call advance(non-bidi iterator, -1)
+
+#include <iterator>
+
+#include "check_assertion.h"
+#include "test_iterators.h"
+
+int main(int, char**) {
+ int a[] = {1, 2, 3};
+
+ bidirectional_iterator<int *> bidi(a+1);
+ std::advance(bidi, 1); // should work fine
+ std::advance(bidi, 0); // should work fine
+ std::advance(bidi, -1); // should work fine
+
+ forward_iterator<int *> it(a+1);
+ std::advance(it, 1); // should work fine
+ std::advance(it, 0); // should work fine
+ TEST_LIBCPP_ASSERT_FAILURE(std::advance(it, -1), "Attempt to advance(it, n) with negative n on a non-bidirectional iterator");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <list>
+
+// Call next(non-bidi iterator, -1)
+
+#include <iterator>
+
+#include "check_assertion.h"
+#include "test_iterators.h"
+
+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
+ TEST_LIBCPP_ASSERT_FAILURE(std::next(it, -1), "Attempt to next(it, n) with negative n on a non-bidirectional iterator");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <list>
+
+// Call prev(forward_iterator, -1)
+
+#include <iterator>
+
+#include "check_assertion.h"
+#include "test_iterators.h"
+
+int main(int, char**) {
+ int a[] = {1, 2, 3};
+
+ bidirectional_iterator<int *> bidi(a+1);
+ std::prev(bidi, -1); // should work fine
+ std::prev(bidi, 0); // should work fine
+ std::prev(bidi, 1); // should work fine
+
+ forward_iterator<int *> it(a+1);
+ std::prev(it, -1); // should work fine
+ std::prev(it, 0); // should work fine
+ TEST_LIBCPP_ASSERT_FAILURE(std::prev(it, 1), "Attempt to prev(it, n) with a positive n on a non-bidirectional iterator");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// <list>
-
-// Call next(non-bidi iterator, -1)
-
-#include <iterator>
-#include "test_macros.h"
-#include "debug_mode_helper.h"
-
-#include "test_iterators.h"
-
-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
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// <list>
-
-// Call prev(forward_iterator, -1)
-
-#include <iterator>
-#include "test_macros.h"
-#include "debug_mode_helper.h"
-
-#include "test_iterators.h"
-
-int main(int, char**)
-{
- int a[] = {1, 2, 3};
-
- bidirectional_iterator<int *> bidi(a+1);
- std::prev(bidi, -1); // should work fine
- std::prev(bidi, 0); // should work fine
- std::prev(bidi, 1); // should work fine
-
- 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
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call back() on empty container.
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <string>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call back() on empty const container.
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <string>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call front() on empty const container.
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <string>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Index const string out of bounds.
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <string>
+#include <cassert>
+
+#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::string S;
+ const S s;
+ assert(s[0] == 0);
+ TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call front() on empty container.
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <string>
+#include <cassert>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Index string out of bounds.
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <string>
+#include <cassert>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ 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;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// const charT& back() const;
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- std::string const s;
- TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// charT& back();
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- std::string s;
- TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Call back() on empty container.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string S;
- S s(1, '\0');
- assert(s.back() == 0);
- s.clear();
- TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Call back() on empty container.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Call back() on empty const container.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string S;
- const S s;
- TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Call back() on empty const container.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "debug_macros.h"
-#include "test_macros.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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Call front() on empty const container.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string S;
- const S s;
- TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Call front() on empty const container.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "debug_macros.h"
-#include "test_macros.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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Index const string out of bounds.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string S;
- const S s;
- assert(s[0] == 0);
- TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Index const string out of bounds.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Call front() on empty container.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string S;
- S s(1, '\0');
- assert(s.front() == 0);
- s.clear();
- TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Call front() on empty container.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Index string out of bounds.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string S;
- S s;
- assert(s[0] == 0);
- TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Index string out of bounds.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.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");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// const charT& front() const;
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- std::string const s;
- TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// charT& front();
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- std::string s;
- TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// const_reference operator[](size_type pos) const;
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- std::string const s;
- char c = s[0];
- assert(c == '\0');
- TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// reference operator[](size_type pos);
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- std::string s;
- char c = s[0];
- assert(c == '\0');
- TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Subtract iterators from different containers with <.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S s1;
- S s2;
- TEST_LIBCPP_ASSERT_FAILURE(s1.begin() - s2.begin(), "Attempted to subtract incompatible iterators");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Index iterator out of bounds.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
- C c(1, '\0');
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Add to iterator out of bounds.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
- C c(1, '\0');
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Decrement iterator prior to begin.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
- C c(1, '\0');
- C::iterator i = c.end();
- --i;
- assert(i == c.begin());
- TEST_LIBCPP_ASSERT_FAILURE(--i, "Attempted to decrement a non-decrementable iterator");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Increment iterator past end.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
- C c(1, '\0');
- C::iterator i = c.begin();
- ++i;
- assert(i == c.end());
- TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Dereference non-dereferenceable iterator.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
- C c(1, '\0');
- C::iterator i = c.end();
- TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Compare iterators from different containers with <.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string S;
- S s1;
- S s2;
- TEST_LIBCPP_ASSERT_FAILURE(s1.begin() < s2.begin(), "Attempted to compare incomparable iterators");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Subtract iterators from different containers with <.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string S;
- S s1;
- S s2;
- TEST_LIBCPP_ASSERT_FAILURE(s1.begin() - s2.begin(), "Attempted to subtract incompatible iterators");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Index iterator out of bounds.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string C;
- C c(1, '\0');
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Add to iterator out of bounds.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string C;
- C c(1, '\0');
- 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;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Decrement iterator prior to begin.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string C;
- C c(1, '\0');
- C::iterator i = c.end();
- --i;
- assert(i == c.begin());
- TEST_LIBCPP_ASSERT_FAILURE(--i, "Attempted to decrement a non-decrementable iterator");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Increment iterator past end.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string C;
- C c(1, '\0');
- C::iterator i = c.begin();
- ++i;
- assert(i == c.end());
- TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Dereference non-dereferenceable iterator.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- typedef std::string C;
- C c(1, '\0');
- C::iterator i = c.end();
- TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Compare iterators from different containers with <.
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S s1;
- S s2;
- TEST_LIBCPP_ASSERT_FAILURE(s1.begin() < s2.begin(), "Attempted to compare incomparable iterators");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Add to iterator out of bounds.
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <string>
+#include <cassert>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ 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 std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
+ C c(1, '\0');
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Compare iterators from different containers with <.
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <string>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ typedef std::string S;
+ S s1;
+ S s2;
+ TEST_LIBCPP_ASSERT_FAILURE(s1.begin() < s2.begin(), "Attempted to compare incomparable iterators");
+ }
+
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
+ S s1;
+ S s2;
+ TEST_LIBCPP_ASSERT_FAILURE(s1.begin() < s2.begin(), "Attempted to compare incomparable iterators");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Decrement iterator prior to begin.
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <string>
+#include <cassert>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ TEST_LIBCPP_ASSERT_FAILURE(--i, "Attempted to decrement a non-decrementable iterator");
+ }
+
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
+ C c(1, '\0');
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ TEST_LIBCPP_ASSERT_FAILURE(--i, "Attempted to decrement a non-decrementable iterator");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Dereference non-dereferenceable iterator.
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <string>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.end();
+ TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator");
+ }
+
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
+ C c(1, '\0');
+ C::iterator i = c.end();
+ TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Increment iterator past end.
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <string>
+#include <cassert>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
+ }
+
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Index iterator out of bounds.
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <string>
+#include <cassert>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ typedef std::string C;
+ C c(1, '\0');
+ 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 std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
+ C c(1, '\0');
+ 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;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Subtract iterators from different containers.
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <string>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ typedef std::string S;
+ S s1;
+ S s2;
+ TEST_LIBCPP_ASSERT_FAILURE(s1.begin() - s2.begin(), "Attempted to subtract incompatible iterators");
+ }
+
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
+ S s1;
+ S s2;
+ TEST_LIBCPP_ASSERT_FAILURE(s1.begin() - s2.begin(), "Attempted to subtract incompatible iterators");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator position) with end()
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <string>
+
+#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 l1("123");
+ S::const_iterator i = l1.end();
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "string::erase(iterator) called with a non-dereferenceable iterator");
+ }
+
+ {
+ std::string l1("123");
+ std::string::const_iterator i = l1.end();
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "string::erase(iterator) called with a non-dereferenceable iterator");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void pop_back();
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <string>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ std::string s;
+ TEST_LIBCPP_ASSERT_FAILURE(s.pop_back(), "string::pop_back(): string is already empty");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator position) with an iterator from another container
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <string>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+ {
+ std::string l1("123");
+ std::string l2("123");
+ std::string::const_iterator i = l2.begin();
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "string::erase(iterator) called with an iterator not referring to this string");
+ }
+
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
+ S l1("123");
+ S l2("123");
+ S::const_iterator i = l2.begin();
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "string::erase(iterator) called with an iterator not referring to this string");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// 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 <string>
+
+#include "check_assertion.h"
+#include "min_allocator.h"
+
+int main(int, char**) {
+
+ // With first iterator from another container
+ {
+ {
+ std::string l1("123");
+ std::string l2("123");
+ TEST_LIBCPP_ASSERT_FAILURE(
+ l1.erase(l2.cbegin(), l1.cbegin() + 1),
+ "string::erase(iterator, iterator) called with an iterator not referring to this string");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
+ S l1("123");
+ S l2("123");
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l2.cbegin(), l1.cbegin() + 1),
+ "string::erase(iterator, iterator) called with an iterator not referring to this string");
+ }
+ }
+
+ // With second iterator from another container
+ {
+ {
+ std::string l1("123");
+ std::string l2("123");
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin(), l2.cbegin() + 1), "Attempted to compare incomparable iterators");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
+ S l1("123");
+ S l2("123");
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin(), l2.cbegin() + 1), "Attempted to compare incomparable iterators");
+ }
+ }
+
+ // With both iterators from another container
+ {
+ {
+ std::string l1("123");
+ std::string l2("123");
+ TEST_LIBCPP_ASSERT_FAILURE(
+ l1.erase(l2.cbegin(), l2.cbegin() + 1),
+ "string::erase(iterator, iterator) called with an iterator not referring to this string");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
+ S l1("123");
+ S l2("123");
+ TEST_LIBCPP_ASSERT_FAILURE(
+ l1.erase(l2.cbegin(), l2.cbegin() + 1),
+ "string::erase(iterator, iterator) called with an iterator not referring to this string");
+ }
+ }
+
+ // With an invalid range
+ {
+ {
+ std::string l1("123");
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin() + 1, l1.cbegin()),
+ "string::erase(first, last) called with invalid range");
+ }
+ {
+ typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
+ S l1("123");
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin() + 1, l1.cbegin()),
+ "string::erase(first, last) called with invalid range");
+ }
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, charT c);
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+// TODO: Since string::insert(iter, char) is intantiated in the dylib, this test doesn't
+// actually work if the dylib hasn't been built with debug assertions enabled.
+// Until we overhaul the debug mode, mark this test as unsupported to avoid
+// spurious CI failures.
+// REQUIRES: never-run
+
+#include <string>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ typedef std::string S;
+ S s;
+ S s2;
+ TEST_LIBCPP_ASSERT_FAILURE(s.insert(s2.begin(), '1'),
+ "string::insert(iterator, character) called with an iterator not referring to this string");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class InputIterator>
+// iterator insert(const_iterator p, InputIterator first, InputIterator last);
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <string>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ std::string v;
+ std::string v2;
+ char a[] = "123";
+ const int N = sizeof(a)/sizeof(a[0]);
+ TEST_LIBCPP_ASSERT_FAILURE(v.insert(v2.cbegin() + 10, a, a + N),
+ "Attempted to add/subtract an iterator outside its valid range");
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, size_type n, charT c);
+
+// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
+
+#include <string>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ std::string s;
+ std::string s2;
+ TEST_LIBCPP_ASSERT_FAILURE(
+ s.insert(s2.begin(), 1, 'a'),
+ "string::insert(iterator, n, value) called with an iterator not referring to this string");
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Call erase(const_iterator position) with end()
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**)
-{
- std::string l1("123");
- std::string::const_iterator i = l1.end();
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "string::erase(iterator) called with a non-dereferenceable iterator");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Call erase(const_iterator position) with iterator from another container
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**)
-{
- std::string l1("123");
- std::string l2("123");
- std::string::const_iterator i = l2.begin();
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i),
- "string::erase(iterator) called with an iterator not referring to this string");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Call erase(const_iterator position) with end()
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S l1("123");
- S::const_iterator i = l1.end();
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "string::erase(iterator) called with a non-dereferenceable iterator");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// Call erase(const_iterator position) with iterator from another container
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S l1("123");
- S l2("123");
- S::const_iterator i = l2.begin();
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i),
- "string::erase(iterator) called with an iterator not referring to this string");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// 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 <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**)
-{
- std::string l1("123");
- std::string l2("123");
- TEST_LIBCPP_ASSERT_FAILURE(
- l1.erase(l2.cbegin(), l1.cbegin() + 1),
- "string::erase(iterator, iterator) called with an iterator not referring to this string");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// 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 <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**)
-{
- std::string l1("123");
- std::string l2("123");
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin(), l2.cbegin() + 1), "Attempted to compare incomparable iterators");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// 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 <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**)
-{
- std::string l1("123");
- std::string l2("123");
- TEST_LIBCPP_ASSERT_FAILURE(
- l1.erase(l2.cbegin(), l2.cbegin() + 1),
- "string::erase(iterator, iterator) called with an iterator not referring to this string");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// 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 <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**)
-{
- std::string l1("123");
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin() + 1, l1.cbegin()),
- "string::erase(first, last) called with invalid range");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// 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 <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S l1("123");
- S l2("123");
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l2.cbegin(), l1.cbegin() + 1),
- "string::erase(iterator, iterator) called with an iterator not referring to this string");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// 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 <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S l1("123");
- S l2("123");
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin(), l2.cbegin() + 1), "Attempted to compare incomparable iterators");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// 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 <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S l1("123");
- S l2("123");
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin() + 1, l1.cbegin()),
- "string::erase(first, last) called with invalid range");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// 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 <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-#include "min_allocator.h"
-
-int main(int, char**) {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S l1("123");
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin() + 1, l1.cbegin()),
- "string::erase(first, last) called with invalid range");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// void pop_back();
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**)
-{
- std::string s;
- TEST_LIBCPP_ASSERT_FAILURE(s.pop_back(), "string::pop_back(): string is already empty");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// iterator insert(const_iterator p, charT c);
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-// TODO: Since string::insert(iter, char) is intantiated in the dylib, this test doesn't
-// actually work if the dylib hasn't been built with debug assertions enabled.
-// Until we overhaul the debug mode, mark this test as unsupported to avoid
-// spurious CI failures.
-// REQUIRES: never-run
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**)
-{
- typedef std::string S;
- S s;
- S s2;
- TEST_LIBCPP_ASSERT_FAILURE(s.insert(s2.begin(), '1'),
- "string::insert(iterator, character) called with an iterator not referring to this string");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// template<class InputIterator>
-// iterator insert(const_iterator p, InputIterator first, InputIterator last);
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**)
-{
- std::string v;
- std::string v2;
- char a[] = "123";
- const int N = sizeof(a)/sizeof(a[0]);
- TEST_LIBCPP_ASSERT_FAILURE(v.insert(v2.cbegin() + 10, a, a + N),
- "Attempted to add/subtract an iterator outside its valid range");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// <string>
-
-// iterator insert(const_iterator p, size_type n, charT c);
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <string>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**)
-{
- std::string s;
- std::string s2;
- TEST_LIBCPP_ASSERT_FAILURE(
- s.insert(s2.begin(), 1, 'a'),
- "string::insert(iterator, n, value) called with an iterator not referring to this string");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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++11, c++14
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+// Construct a string_view from a null pointer
+// constexpr basic_string_view( const CharT* s );
+
+#include <string_view>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ TEST_LIBCPP_ASSERT_FAILURE(std::string_view((char const*)NULL), "null pointer passed to non-null argument of char_traits<...>::length");
+ TEST_LIBCPP_ASSERT_FAILURE(std::string_view((char const*)nullptr), "null pointer passed to non-null argument of char_traits<...>::length");
+ TEST_LIBCPP_ASSERT_FAILURE(std::string_view((char const*)0), "null pointer passed to non-null argument of char_traits<...>::length");
+ {
+ std::string_view v;
+ TEST_LIBCPP_ASSERT_FAILURE(v == (char const*)nullptr, "null pointer passed to non-null argument of char_traits<...>::length");
+ TEST_LIBCPP_ASSERT_FAILURE(v == (char const*)NULL, "null pointer passed to non-null argument of char_traits<...>::length");
+ TEST_LIBCPP_ASSERT_FAILURE((char const*)nullptr == v, "null pointer passed to non-null argument of char_traits<...>::length");
+ TEST_LIBCPP_ASSERT_FAILURE((char const*)NULL == v, "null pointer passed to non-null argument of char_traits<...>::length");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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: libcpp-has-no-threads
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+// <future>
+
+// class promise<R>
+
+// void set_exception(exception_ptr p);
+// Test that a null exception_ptr is diagnosed.
+
+#include <future>
+#include <exception>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ {
+ typedef int T;
+ std::promise<T> p;
+ TEST_LIBCPP_ASSERT_FAILURE(p.set_exception(std::exception_ptr()), "promise::set_exception: received nullptr");
+ }
+
+ {
+ typedef int& T;
+ std::promise<T> p;
+ TEST_LIBCPP_ASSERT_FAILURE(p.set_exception(std::exception_ptr()), "promise::set_exception: received nullptr");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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: libcpp-has-no-threads
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+// <future>
+
+// class promise<R>
+
+// void set_exception_on_thread_exit(exception_ptr p);
+// Test that a null exception_ptr is diagnosed.
+
+#include <future>
+#include <exception>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ {
+ typedef int T;
+ std::promise<T> p;
+ TEST_LIBCPP_ASSERT_FAILURE(p.set_exception_at_thread_exit(std::exception_ptr()), "promise::set_exception_at_thread_exit: received nullptr");
+ }
+
+ {
+ typedef int& T;
+ std::promise<T> p;
+ TEST_LIBCPP_ASSERT_FAILURE(p.set_exception_at_thread_exit(std::exception_ptr()), "promise::set_exception_at_thread_exit: received nullptr");
+ }
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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: windows
-// UNSUPPORTED: libcpp-has-no-threads
-// UNSUPPORTED: c++03
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
-
-// <future>
-
-// class promise<R>
-
-// void set_exception(exception_ptr p);
-// Test that a null exception_ptr is diagnosed.
-
-#include <future>
-#include <exception>
-#include <cstdlib>
-#include <cassert>
-
-#include "test_macros.h"
-#include "debug_mode_helper.h"
-
-int main(int, char**)
-{
- {
- typedef int T;
- std::promise<T> p;
-
- EXPECT_DEATH( p.set_exception(std::exception_ptr()) );
- }
- {
- typedef int& T;
- std::promise<T> p;
-
- EXPECT_DEATH( p.set_exception(std::exception_ptr()) );
- }
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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: windows
-// UNSUPPORTED: libcpp-has-no-threads
-// UNSUPPORTED: c++03
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0
-
-// <future>
-
-// class promise<R>
-
-// void set_exception_on_thread_exit(exception_ptr p);
-// Test that a null exception_ptr is diagnosed.
-
-#include <future>
-#include <exception>
-#include <cstdlib>
-#include <cassert>
-#include "test_macros.h"
-#include "debug_mode_helper.h"
-
-
-int main(int, char**)
-{
- {
- typedef int T;
- std::promise<T> p;
-
- EXPECT_DEATH( p.set_exception_at_thread_exit(std::exception_ptr()) );
-
- }
- {
- typedef int& T;
- std::promise<T> p;
-
- EXPECT_DEATH( p.set_exception_at_thread_exit(std::exception_ptr()) );
- }
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr T& optional<T>::operator*() &;
+// constexpr T&& optional<T>::operator*() &&;
+// constexpr const T& optional<T>::operator*() const &;
+// constexpr T&& optional<T>::operator*() const &&;
+
+// UNSUPPORTED: c++11, c++14
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <optional>
+
+#include "check_assertion.h"
+
+int main(int, char**) {
+ // &
+ {
+ std::optional<int> opt;
+ TEST_LIBCPP_ASSERT_FAILURE(*opt, "optional operator* called on a disengaged value");
+ }
+
+ // &&
+ {
+ std::optional<int> opt;
+ TEST_LIBCPP_ASSERT_FAILURE(*std::move(opt), "optional operator* called on a disengaged value");
+ }
+
+ // const &
+ {
+ const std::optional<int> opt;
+ TEST_LIBCPP_ASSERT_FAILURE(*opt, "optional operator* called on a disengaged value");
+ }
+
+ // const &&
+ {
+ const std::optional<int> opt;
+ TEST_LIBCPP_ASSERT_FAILURE(*std::move(opt), "optional operator* called on a disengaged value");
+ }
+
+ return 0;
+}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr T* optional<T>::operator->();
+// constexpr const T* optional<T>::operator->() const;
+
+// UNSUPPORTED: c++11, c++14
+
+// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
+
+#include <optional>
+
+#include "check_assertion.h"
+
+struct X {
+ int test() const { return 3; }
+};
+
+int main(int, char**) {
+ {
+ std::optional<X> opt;
+ TEST_LIBCPP_ASSERT_FAILURE(opt->test(), "optional operator-> called on a disengaged value");
+ }
+
+ {
+ const std::optional<X> opt;
+ TEST_LIBCPP_ASSERT_FAILURE(opt->test(), "optional operator-> called on a disengaged value");
+ }
+
+ return 0;
+}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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, c++11, c++14
-// <optional>
-
-// constexpr T& optional<T>::operator*() &;
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <optional>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- std::optional<int> opt;
- TEST_LIBCPP_ASSERT_FAILURE(*opt, "optional operator* called on a disengaged value");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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, c++11, c++14
-// <optional>
-
-// constexpr const T& optional<T>::operator*() const &;
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <optional>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- const std::optional<int> opt;
- TEST_LIBCPP_ASSERT_FAILURE(*opt, "optional operator* called on a disengaged value");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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, c++11, c++14
-// <optional>
-
-// constexpr T&& optional<T>::operator*() const &&;
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <optional>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- const std::optional<int> opt;
- TEST_LIBCPP_ASSERT_FAILURE(*std::move(opt), "optional operator* called on a disengaged value");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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, c++11, c++14
-// <optional>
-
-// constexpr T&& optional<T>::operator*() &&;
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <optional>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-int main(int, char**) {
- std::optional<int> opt;
- TEST_LIBCPP_ASSERT_FAILURE(*std::move(opt), "optional operator* called on a disengaged value");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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, c++11, c++14
-// <optional>
-
-// constexpr T* optional<T>::operator->();
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <optional>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-struct X {
- int test() noexcept {return 3;}
-};
-
-int main(int, char**) {
- std::optional<X> opt;
- TEST_LIBCPP_ASSERT_FAILURE(opt->test(), "optional operator-> called on a disengaged value");
-
- return 0;
-}
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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, c++11, c++14
-// <optional>
-
-// constexpr const T* optional<T>::operator->() const;
-
-// UNSUPPORTED: libcxx-no-debug-mode
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-#include <optional>
-
-#include "test_macros.h"
-#include "debug_macros.h"
-
-struct X {
- int test() const {return 3;}
-};
-
-int main(int, char**) {
- const std::optional<X> opt;
- TEST_LIBCPP_ASSERT_FAILURE(opt->test(), "optional operator-> called on a disengaged value");
-
- return 0;
-}
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_SUPPORT_CHECK_ASSERTION_H
+#define TEST_SUPPORT_CHECK_ASSERTION_H
+
+#ifndef _LIBCPP_DEBUG
+#error _LIBCPP_DEBUG must be defined before including this header
+#endif
+
+#include <ciso646>
+#ifndef _LIBCPP_VERSION
+#error "This header may only be used for libc++ tests"
+#endif
+
+#include <__debug>
+#include <cassert>
+#include <cstddef>
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+#include <string_view>
+#include <utility>
+
+#include <unistd.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include "test_macros.h"
+#include "test_allocator.h"
+
+#if TEST_STD_VER < 11
+# error "C++11 or greater is required to use this header"
+#endif
+
+struct DebugInfoMatcher {
+ static const int any_line = -1;
+ static constexpr const char* any_file = "*";
+ static constexpr const char* any_msg = "*";
+
+ constexpr DebugInfoMatcher() : is_empty(true), msg(any_msg, __builtin_strlen(any_msg)), file(any_file, __builtin_strlen(any_file)), line(any_line) { }
+ constexpr DebugInfoMatcher(const char* msg_, const char* file_ = any_file, int line_ = any_line)
+ : is_empty(false), msg(msg_, __builtin_strlen(msg_)), file(file_, __builtin_strlen(file_)), line(line_) {}
+
+ bool Matches(std::__libcpp_debug_info const& got) const {
+ assert(!empty() && "empty matcher");
+
+ if (CheckLineMatches(got.__line_) && CheckFileMatches(got.__file_) &&
+ CheckMessageMatches(got.__msg_))
+ return true;
+ // Write to stdout because that's the file descriptor captured by the parent
+ // process.
+ std::printf("Failed to match debug info!\n%s\nVS\n%s\n", ToString().data(), got.what().data());
+ return false;
+ }
+
+ std::string ToString() const {
+ std::string result = "msg = \""; result += msg; result += "\"\n";
+ result += "line = " + (line == any_line ? "'*'" : std::to_string(line)) + "\n";
+ result += "file = " + (file == any_file ? "'*'" : std::string(any_file));
+ return result;
+ }
+
+ bool empty() const { return is_empty; }
+private:
+ bool CheckLineMatches(int got_line) const {
+ if (line == any_line)
+ return true;
+ return got_line == line;
+ }
+
+ bool CheckFileMatches(std::string_view got_file) const {
+ assert(!empty() && "empty matcher");
+ if (file == any_file)
+ return true;
+ std::size_t found_at = got_file.find(file);
+ if (found_at == std::string_view::npos)
+ return false;
+ // require the match start at the beginning of the file or immediately after
+ // a directory separator.
+ if (found_at != 0) {
+ char last_char = got_file[found_at - 1];
+ if (last_char != '/' && last_char != '\\')
+ return false;
+ }
+ // require the match goes until the end of the string.
+ return got_file.substr(found_at) == file;
+ }
+
+ bool CheckMessageMatches(std::string_view got_msg) const {
+ assert(!empty() && "empty matcher");
+ if (msg == any_msg)
+ return true;
+ std::size_t found_at = got_msg.find(msg);
+ if (found_at == std::string_view::npos)
+ return false;
+ // Allow any match
+ return true;
+ }
+private:
+ bool is_empty;
+ std::string_view msg;
+ std::string_view file;
+ int line;
+};
+
+static constexpr DebugInfoMatcher AnyMatcher(DebugInfoMatcher::any_msg);
+
+inline DebugInfoMatcher& GlobalMatcher() {
+ static DebugInfoMatcher GMatch;
+ return GMatch;
+}
+
+struct DeathTest {
+ enum ResultKind {
+ RK_DidNotDie, RK_MatchFound, RK_MatchFailure, RK_SetupFailure, RK_Unknown
+ };
+
+ static const char* ResultKindToString(ResultKind RK) {
+#define CASE(K) case K: return #K
+ switch (RK) {
+ CASE(RK_MatchFailure);
+ CASE(RK_DidNotDie);
+ CASE(RK_SetupFailure);
+ CASE(RK_MatchFound);
+ CASE(RK_Unknown);
+ }
+ return "not a result kind";
+ }
+
+ static bool IsValidResultKind(int val) {
+ return val >= RK_DidNotDie && val <= RK_Unknown;
+ }
+
+ TEST_NORETURN static void DeathTestDebugHandler(std::__libcpp_debug_info const& info) {
+ assert(!GlobalMatcher().empty());
+ if (GlobalMatcher().Matches(info)) {
+ std::exit(RK_MatchFound);
+ }
+ std::exit(RK_MatchFailure);
+ }
+
+
+ DeathTest(DebugInfoMatcher const& Matcher) : matcher_(Matcher) {}
+
+ template <class Func>
+ ResultKind Run(Func&& f) {
+ int pipe_res = pipe(stdout_pipe_fd_);
+ assert(pipe_res != -1 && "failed to create pipe");
+ pipe_res = pipe(stderr_pipe_fd_);
+ assert(pipe_res != -1 && "failed to create pipe");
+ pid_t child_pid = fork();
+ assert(child_pid != -1 &&
+ "failed to fork a process to perform a death test");
+ child_pid_ = child_pid;
+ if (child_pid_ == 0) {
+ RunForChild(std::forward<Func>(f));
+ assert(false && "unreachable");
+ }
+ return RunForParent();
+ }
+
+ int getChildExitCode() const { return exit_code_; }
+ std::string const& getChildStdOut() const { return stdout_from_child_; }
+ std::string const& getChildStdErr() const { return stderr_from_child_; }
+private:
+ template <class Func>
+ TEST_NORETURN void RunForChild(Func&& f) {
+ close(GetStdOutReadFD()); // don't need to read from the pipe in the child.
+ close(GetStdErrReadFD());
+ auto DupFD = [](int DestFD, int TargetFD) {
+ int dup_result = dup2(DestFD, TargetFD);
+ if (dup_result == -1)
+ std::exit(RK_SetupFailure);
+ };
+ DupFD(GetStdOutWriteFD(), STDOUT_FILENO);
+ DupFD(GetStdErrWriteFD(), STDERR_FILENO);
+
+ GlobalMatcher() = matcher_;
+ std::__libcpp_set_debug_function(&DeathTestDebugHandler);
+ f();
+ std::exit(RK_DidNotDie);
+ }
+
+ static std::string ReadChildIOUntilEnd(int FD) {
+ std::string error_msg;
+ char buffer[256];
+ int num_read;
+ do {
+ while ((num_read = read(FD, buffer, 255)) > 0) {
+ buffer[num_read] = '\0';
+ error_msg += buffer;
+ }
+ } while (num_read == -1 && errno == EINTR);
+ return error_msg;
+ }
+
+ void CaptureIOFromChild() {
+ close(GetStdOutWriteFD()); // no need to write from the parent process
+ close(GetStdErrWriteFD());
+ stdout_from_child_ = ReadChildIOUntilEnd(GetStdOutReadFD());
+ stderr_from_child_ = ReadChildIOUntilEnd(GetStdErrReadFD());
+ close(GetStdOutReadFD());
+ close(GetStdErrReadFD());
+ }
+
+ ResultKind RunForParent() {
+ CaptureIOFromChild();
+
+ int status_value;
+ pid_t result = waitpid(child_pid_, &status_value, 0);
+ assert(result != -1 && "there is no child process to wait for");
+
+ if (WIFEXITED(status_value)) {
+ exit_code_ = WEXITSTATUS(status_value);
+ if (!IsValidResultKind(exit_code_))
+ return RK_Unknown;
+ return static_cast<ResultKind>(exit_code_);
+ }
+ return RK_Unknown;
+ }
+
+ DeathTest(DeathTest const&) = delete;
+ DeathTest& operator=(DeathTest const&) = delete;
+
+ int GetStdOutReadFD() const {
+ return stdout_pipe_fd_[0];
+ }
+
+ int GetStdOutWriteFD() const {
+ return stdout_pipe_fd_[1];
+ }
+
+ int GetStdErrReadFD() const {
+ return stderr_pipe_fd_[0];
+ }
+
+ int GetStdErrWriteFD() const {
+ return stderr_pipe_fd_[1];
+ }
+private:
+ DebugInfoMatcher matcher_;
+ pid_t child_pid_ = -1;
+ int exit_code_ = -1;
+ int stdout_pipe_fd_[2];
+ int stderr_pipe_fd_[2];
+ std::string stdout_from_child_;
+ std::string stderr_from_child_;
+};
+
+template <class Func>
+inline bool ExpectDeath(const char* stmt, Func&& func, DebugInfoMatcher Matcher) {
+ DeathTest DT(Matcher);
+ DeathTest::ResultKind RK = DT.Run(func);
+ auto OnFailure = [&](const char* msg) {
+ std::fprintf(stderr, "EXPECT_DEATH( %s ) failed! (%s)\n\n", stmt, msg);
+ if (RK != DeathTest::RK_Unknown) {
+ std::fprintf(stderr, "child exit code: %d\n", DT.getChildExitCode());
+ }
+ if (!DT.getChildStdErr().empty()) {
+ std::fprintf(stderr, "---------- standard err ----------\n%s\n", DT.getChildStdErr().c_str());
+ }
+ if (!DT.getChildStdOut().empty()) {
+ std::fprintf(stderr, "---------- standard out ----------\n%s\n", DT.getChildStdOut().c_str());
+ }
+ return false;
+ };
+ switch (RK) {
+ case DeathTest::RK_MatchFound:
+ return true;
+ case DeathTest::RK_SetupFailure:
+ return OnFailure("child failed to setup test environment");
+ case DeathTest::RK_Unknown:
+ return OnFailure("reason unknown");
+ case DeathTest::RK_DidNotDie:
+ return OnFailure("child did not die");
+ case DeathTest::RK_MatchFailure:
+ return OnFailure("matcher failed");
+ }
+ assert(false && "unreachable");
+}
+
+template <class Func>
+inline bool ExpectDeath(const char* stmt, Func&& func) {
+ return ExpectDeath(stmt, func, AnyMatcher);
+}
+
+/// Assert that the specified expression throws a libc++ debug exception.
+#define EXPECT_DEATH(...) assert((ExpectDeath(#__VA_ARGS__, [&]() { __VA_ARGS__; } )))
+
+#define EXPECT_DEATH_MATCHES(Matcher, ...) assert((ExpectDeath(#__VA_ARGS__, [&]() { __VA_ARGS__; }, Matcher)))
+
+#define TEST_LIBCPP_ASSERT_FAILURE(expr, message) assert((ExpectDeath(#expr, [&]() { (void)(expr); }, DebugInfoMatcher(message))))
+
+#endif // TEST_SUPPORT_CHECK_ASSERTION_H
#include <cstdlib>
#include <cassert>
-#include "test_macros.h"
-#include "debug_mode_helper.h"
+#include "check_assertion.h"
#include "test_allocator.h"
+#include "test_macros.h"
// These test make use of 'if constexpr'.
#if TEST_STD_VER <= 14
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef TEST_SUPPORT_DEBUG_MACROS_H
-#define TEST_SUPPORT_DEBUG_MACROS_H
-
-#include <__debug>
-#include <cassert>
-#include <string>
-
-static const char* expected_libcpp_assert_message = 0;
-
-static void test_debug_function(std::__libcpp_debug_info const& info) {
- if (0 == std::strcmp(info.__msg_, expected_libcpp_assert_message))
- std::exit(0);
- std::fprintf(stderr, "%s\n", info.what().c_str());
- std::abort();
-}
-
-#define TEST_LIBCPP_ASSERT_FAILURE(expr, m) \
- do { \
- ::expected_libcpp_assert_message = m; \
- std::__libcpp_set_debug_function(&::test_debug_function); \
- (void)(expr); \
- assert(false); \
- } while (false)
-
-#endif // TEST_SUPPORT_DEBUG_MACROS_H
+++ /dev/null
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef TEST_SUPPORT_DEBUG_MODE_HELPER_H
-#define TEST_SUPPORT_DEBUG_MODE_HELPER_H
-
-#ifndef _LIBCPP_DEBUG
-#error _LIBCPP_DEBUG must be defined before including this header
-#endif
-
-#include <ciso646>
-#ifndef _LIBCPP_VERSION
-#error "This header may only be used for libc++ tests"
-#endif
-
-#include <__debug>
-#include <cassert>
-#include <cstddef>
-#include <cstdio>
-#include <cstdlib>
-#include <string>
-#include <string_view>
-#include <utility>
-
-#include <unistd.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include "test_macros.h"
-#include "test_allocator.h"
-
-#if TEST_STD_VER < 11
-# error "C++11 or greater is required to use this header"
-#endif
-
-struct DebugInfoMatcher {
- static const int any_line = -1;
- static constexpr const char* any_file = "*";
- static constexpr const char* any_msg = "*";
-
- constexpr DebugInfoMatcher() : is_empty(true), msg(any_msg, __builtin_strlen(any_msg)), file(any_file, __builtin_strlen(any_file)), line(any_line) { }
- constexpr DebugInfoMatcher(const char* msg_, const char* file_ = any_file, int line_ = any_line)
- : is_empty(false), msg(msg_, __builtin_strlen(msg_)), file(file_, __builtin_strlen(file_)), line(line_) {}
-
- bool Matches(std::__libcpp_debug_info const& got) const {
- assert(!empty() && "empty matcher");
-
- if (CheckLineMatches(got.__line_) && CheckFileMatches(got.__file_) &&
- CheckMessageMatches(got.__msg_))
- return true;
- // Write to stdout because that's the file descriptor captured by the parent
- // process.
- std::printf("Failed to match debug info!\n%s\nVS\n%s\n", ToString().data(), got.what().data());
- return false;
- }
-
- std::string ToString() const {
- std::string result = "msg = \""; result += msg; result += "\"\n";
- result += "line = " + (line == any_line ? "'*'" : std::to_string(line)) + "\n";
- result += "file = " + (file == any_file ? "'*'" : std::string(any_file));
- return result;
- }
-
- bool empty() const { return is_empty; }
-private:
- bool CheckLineMatches(int got_line) const {
- if (line == any_line)
- return true;
- return got_line == line;
- }
-
- bool CheckFileMatches(std::string_view got_file) const {
- assert(!empty() && "empty matcher");
- if (file == any_file)
- return true;
- std::size_t found_at = got_file.find(file);
- if (found_at == std::string_view::npos)
- return false;
- // require the match start at the beginning of the file or immediately after
- // a directory separator.
- if (found_at != 0) {
- char last_char = got_file[found_at - 1];
- if (last_char != '/' && last_char != '\\')
- return false;
- }
- // require the match goes until the end of the string.
- return got_file.substr(found_at) == file;
- }
-
- bool CheckMessageMatches(std::string_view got_msg) const {
- assert(!empty() && "empty matcher");
- if (msg == any_msg)
- return true;
- std::size_t found_at = got_msg.find(msg);
- if (found_at == std::string_view::npos)
- return false;
- // Allow any match
- return true;
- }
-private:
- bool is_empty;
- std::string_view msg;
- std::string_view file;
- int line;
-};
-
-static constexpr DebugInfoMatcher AnyMatcher(DebugInfoMatcher::any_msg);
-
-inline DebugInfoMatcher& GlobalMatcher() {
- static DebugInfoMatcher GMatch;
- return GMatch;
-}
-
-struct DeathTest {
- enum ResultKind {
- RK_DidNotDie, RK_MatchFound, RK_MatchFailure, RK_SetupFailure, RK_Unknown
- };
-
- static const char* ResultKindToString(ResultKind RK) {
-#define CASE(K) case K: return #K
- switch (RK) {
- CASE(RK_MatchFailure);
- CASE(RK_DidNotDie);
- CASE(RK_SetupFailure);
- CASE(RK_MatchFound);
- CASE(RK_Unknown);
- }
- return "not a result kind";
- }
-
- static bool IsValidResultKind(int val) {
- return val >= RK_DidNotDie && val <= RK_Unknown;
- }
-
- TEST_NORETURN static void DeathTestDebugHandler(std::__libcpp_debug_info const& info) {
- assert(!GlobalMatcher().empty());
- if (GlobalMatcher().Matches(info)) {
- std::exit(RK_MatchFound);
- }
- std::exit(RK_MatchFailure);
- }
-
-
- DeathTest(DebugInfoMatcher const& Matcher) : matcher_(Matcher) {}
-
- template <class Func>
- ResultKind Run(Func&& f) {
- int pipe_res = pipe(stdout_pipe_fd_);
- assert(pipe_res != -1 && "failed to create pipe");
- pipe_res = pipe(stderr_pipe_fd_);
- assert(pipe_res != -1 && "failed to create pipe");
- pid_t child_pid = fork();
- assert(child_pid != -1 &&
- "failed to fork a process to perform a death test");
- child_pid_ = child_pid;
- if (child_pid_ == 0) {
- RunForChild(std::forward<Func>(f));
- assert(false && "unreachable");
- }
- return RunForParent();
- }
-
- int getChildExitCode() const { return exit_code_; }
- std::string const& getChildStdOut() const { return stdout_from_child_; }
- std::string const& getChildStdErr() const { return stderr_from_child_; }
-private:
- template <class Func>
- TEST_NORETURN void RunForChild(Func&& f) {
- close(GetStdOutReadFD()); // don't need to read from the pipe in the child.
- close(GetStdErrReadFD());
- auto DupFD = [](int DestFD, int TargetFD) {
- int dup_result = dup2(DestFD, TargetFD);
- if (dup_result == -1)
- std::exit(RK_SetupFailure);
- };
- DupFD(GetStdOutWriteFD(), STDOUT_FILENO);
- DupFD(GetStdErrWriteFD(), STDERR_FILENO);
-
- GlobalMatcher() = matcher_;
- std::__libcpp_set_debug_function(&DeathTestDebugHandler);
- f();
- std::exit(RK_DidNotDie);
- }
-
- static std::string ReadChildIOUntilEnd(int FD) {
- std::string error_msg;
- char buffer[256];
- int num_read;
- do {
- while ((num_read = read(FD, buffer, 255)) > 0) {
- buffer[num_read] = '\0';
- error_msg += buffer;
- }
- } while (num_read == -1 && errno == EINTR);
- return error_msg;
- }
-
- void CaptureIOFromChild() {
- close(GetStdOutWriteFD()); // no need to write from the parent process
- close(GetStdErrWriteFD());
- stdout_from_child_ = ReadChildIOUntilEnd(GetStdOutReadFD());
- stderr_from_child_ = ReadChildIOUntilEnd(GetStdErrReadFD());
- close(GetStdOutReadFD());
- close(GetStdErrReadFD());
- }
-
- ResultKind RunForParent() {
- CaptureIOFromChild();
-
- int status_value;
- pid_t result = waitpid(child_pid_, &status_value, 0);
- assert(result != -1 && "there is no child process to wait for");
-
- if (WIFEXITED(status_value)) {
- exit_code_ = WEXITSTATUS(status_value);
- if (!IsValidResultKind(exit_code_))
- return RK_Unknown;
- return static_cast<ResultKind>(exit_code_);
- }
- return RK_Unknown;
- }
-
- DeathTest(DeathTest const&) = delete;
- DeathTest& operator=(DeathTest const&) = delete;
-
- int GetStdOutReadFD() const {
- return stdout_pipe_fd_[0];
- }
-
- int GetStdOutWriteFD() const {
- return stdout_pipe_fd_[1];
- }
-
- int GetStdErrReadFD() const {
- return stderr_pipe_fd_[0];
- }
-
- int GetStdErrWriteFD() const {
- return stderr_pipe_fd_[1];
- }
-private:
- DebugInfoMatcher matcher_;
- pid_t child_pid_ = -1;
- int exit_code_ = -1;
- int stdout_pipe_fd_[2];
- int stderr_pipe_fd_[2];
- std::string stdout_from_child_;
- std::string stderr_from_child_;
-};
-
-template <class Func>
-inline bool ExpectDeath(const char* stmt, Func&& func, DebugInfoMatcher Matcher) {
- DeathTest DT(Matcher);
- DeathTest::ResultKind RK = DT.Run(func);
- auto OnFailure = [&](const char* msg) {
- std::fprintf(stderr, "EXPECT_DEATH( %s ) failed! (%s)\n\n", stmt, msg);
- if (RK != DeathTest::RK_Unknown) {
- std::fprintf(stderr, "child exit code: %d\n", DT.getChildExitCode());
- }
- if (!DT.getChildStdErr().empty()) {
- std::fprintf(stderr, "---------- standard err ----------\n%s\n", DT.getChildStdErr().c_str());
- }
- if (!DT.getChildStdOut().empty()) {
- std::fprintf(stderr, "---------- standard out ----------\n%s\n", DT.getChildStdOut().c_str());
- }
- return false;
- };
- switch (RK) {
- case DeathTest::RK_MatchFound:
- return true;
- case DeathTest::RK_SetupFailure:
- return OnFailure("child failed to setup test environment");
- case DeathTest::RK_Unknown:
- return OnFailure("reason unknown");
- case DeathTest::RK_DidNotDie:
- return OnFailure("child did not die");
- case DeathTest::RK_MatchFailure:
- return OnFailure("matcher failed");
- }
- assert(false && "unreachable");
-}
-
-template <class Func>
-inline bool ExpectDeath(const char* stmt, Func&& func) {
- return ExpectDeath(stmt, func, AnyMatcher);
-}
-
-/// Assert that the specified expression throws a libc++ debug exception.
-#define EXPECT_DEATH(...) assert((ExpectDeath(#__VA_ARGS__, [&]() { __VA_ARGS__; } )))
-
-#define EXPECT_DEATH_MATCHES(Matcher, ...) assert((ExpectDeath(#__VA_ARGS__, [&]() { __VA_ARGS__; }, Matcher)))
-
-#endif // TEST_SUPPORT_DEBUG_MODE_HELPER_H
help="The debugging level to enable in the test suite.",
actions=lambda debugLevel: [] if debugLevel == '' else filter(None, [
AddFeature('debug_level={}'.format(debugLevel)),
+ AddCompileFlag('-Wno-macro-redefined'),
AddCompileFlag('-D_LIBCPP_DEBUG={}'.format(debugLevel)),
AddFeature('LIBCXX-DEBUG-FIXME') if debugLevel == '1' else None
])),