diff --git a/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp b/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// template 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 +#include + +#include "check_assertion.h" + +template +struct MyType { + int value; + explicit MyType(int xvalue = 0) : value(xvalue) {} +}; + +template +bool operator<(MyType const& LHS, MyType const& RHS) { + return LHS.value < RHS.value; +} + +template +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 c; + std::__debug_less> d(c); + + TEST_LIBCPP_ASSERT_FAILURE(d(one, two), "Comparator does not induce a strict weak ordering"); + + return 0; +} diff --git a/libcxx/test/libcxx/algorithms/debug_less.pass.cpp b/libcxx/test/libcxx/algorithms/debug_less.pass.cpp --- a/libcxx/test/libcxx/algorithms/debug_less.pass.cpp +++ b/libcxx/test/libcxx/algorithms/debug_less.pass.cpp @@ -12,8 +12,7 @@ // __debug_less checks that a comparator actually provides a strict-weak ordering. -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include @@ -21,7 +20,7 @@ #include #include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" template struct MyType { @@ -51,14 +50,6 @@ } }; -template -struct BadComparator : public CompareBase { - bool operator()(ValueType const&, ValueType const&) const { - ++CompareBase::called; - return true; - } -}; - template struct TwoWayHomoComparator : public CompareBase { bool operator()(T1 const& lhs, T2 const& rhs) const { @@ -138,20 +129,6 @@ } } -void test_failing() { - MT0 one(1); - MT0 two(2); - - { - typedef BadComparator C; - typedef __debug_less D; - C c; - D d(c); - - TEST_LIBCPP_ASSERT_FAILURE(d(one, two), "Comparator does not induce a strict weak ordering"); - } -} - template struct Tag { explicit Tag(int v) : value(v) {} @@ -271,7 +248,6 @@ int main(int, char**) { test_passing(); - test_failing(); test_upper_and_lower_bound(); test_non_const_arg_cmp(); test_value_iterator(); diff --git a/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.back.pass.cpp b/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.back.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.back.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 + +// test that array::back() triggers an assertion + +#include + +#include "check_assertion.h" + +int main(int, char**) { + { + typedef std::array C; + C c = {}; + C const& cc = c; + TEST_LIBCPP_ASSERT_FAILURE(c.back(), "cannot call array::back() on a zero-sized array"); + TEST_LIBCPP_ASSERT_FAILURE(cc.back(), "cannot call array::back() on a zero-sized array"); + } + { + typedef std::array C; + C c = {{}}; + C const& cc = c; + TEST_LIBCPP_ASSERT_FAILURE(c.back(), "cannot call array::back() on a zero-sized array"); + TEST_LIBCPP_ASSERT_FAILURE(cc.back(), "cannot call array::back() on a zero-sized array"); + } + + return 0; +} diff --git a/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.front.pass.cpp b/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.front.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.front.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 + +// test that array::back() triggers an assertion + +#include + +#include "check_assertion.h" + +int main(int, char**) { + { + typedef std::array C; + C c = {}; + C const& cc = c; + TEST_LIBCPP_ASSERT_FAILURE(c.front(), "cannot call array::front() on a zero-sized array"); + TEST_LIBCPP_ASSERT_FAILURE(cc.front(), "cannot call array::front() on a zero-sized array"); + } + { + typedef std::array C; + C c = {{}}; + C const& cc = c; + TEST_LIBCPP_ASSERT_FAILURE(c.front(), "cannot call array::front() on a zero-sized array"); + TEST_LIBCPP_ASSERT_FAILURE(cc.front(), "cannot call array::front() on a zero-sized array"); + } + + return 0; +} diff --git a/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.subscript.pass.cpp b/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.subscript.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/sequences/array/array.zero/assert.subscript.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 + +// test that array::operator[] triggers an assertion + +#include + +#include "check_assertion.h" + +int main(int, char**) { + { + typedef std::array C; + C c = {}; + C const& cc = c; + TEST_LIBCPP_ASSERT_FAILURE(c[0], "cannot call array::operator[] on a zero-sized array"); + TEST_LIBCPP_ASSERT_FAILURE(c[1], "cannot call array::operator[] on a zero-sized array"); + TEST_LIBCPP_ASSERT_FAILURE(cc[0], "cannot call array::operator[] on a zero-sized array"); + TEST_LIBCPP_ASSERT_FAILURE(cc[1], "cannot call array::operator[] on a zero-sized array"); + } + { + typedef std::array C; + C c = {{}}; + C const& cc = c; + TEST_LIBCPP_ASSERT_FAILURE(c[0], "cannot call array::operator[] on a zero-sized array"); + TEST_LIBCPP_ASSERT_FAILURE(c[1], "cannot call array::operator[] on a zero-sized array"); + TEST_LIBCPP_ASSERT_FAILURE(cc[0], "cannot call array::operator[] on a zero-sized array"); + TEST_LIBCPP_ASSERT_FAILURE(cc[1], "cannot call array::operator[] on a zero-sized array"); + } + + return 0; +} diff --git a/libcxx/test/libcxx/containers/sequences/array/array.zero/db_back.pass.cpp b/libcxx/test/libcxx/containers/sequences/array/array.zero/db_back.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/array/array.zero/db_back.pass.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: windows - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 -// UNSUPPORTED: libcxx-no-debug-mode - -// test array::front() raises a debug error. - -#include -#include "test_macros.h" -#include "debug_mode_helper.h" - -int main(int, char**) -{ - { - typedef std::array C; - C c = {}; - C const& cc = c; - EXPECT_DEATH( c.back() ); - EXPECT_DEATH( cc.back() ); - } - { - typedef std::array C; - C c = {{}}; - C const& cc = c; - EXPECT_DEATH( c.back() ); - EXPECT_DEATH( cc.back() ); - } - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/array/array.zero/db_front.pass.cpp b/libcxx/test/libcxx/containers/sequences/array/array.zero/db_front.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/array/array.zero/db_front.pass.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: windows - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 -// UNSUPPORTED: libcxx-no-debug-mode - -// test array::front() raises a debug error. - -#include -#include "test_macros.h" -#include "debug_mode_helper.h" - -int main(int, char**) -{ - { - typedef std::array C; - C c = {}; - C const& cc = c; - EXPECT_DEATH(c.front()); - EXPECT_DEATH(cc.front()); - } - { - typedef std::array C; - C c = {{}}; - C const& cc = c; - EXPECT_DEATH(c.front()); - EXPECT_DEATH(cc.front()); - } - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/array/array.zero/db_indexing.pass.cpp b/libcxx/test/libcxx/containers/sequences/array/array.zero/db_indexing.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/array/array.zero/db_indexing.pass.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: windows - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 -// UNSUPPORTED: libcxx-no-debug-mode - -// test array::operator[] raises a debug error. - -#include -#include "test_macros.h" -#include "debug_mode_helper.h" - -int main(int, char**) -{ - { - typedef std::array 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 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; -} diff --git a/libcxx/test/libcxx/containers/sequences/deque/pop_back_empty.pass.cpp b/libcxx/test/libcxx/containers/sequences/deque/assert.pop_back.empty.pass.cpp rename from libcxx/test/libcxx/containers/sequences/deque/pop_back_empty.pass.cpp rename to libcxx/test/libcxx/containers/sequences/deque/assert.pop_back.empty.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/deque/pop_back_empty.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/deque/assert.pop_back.empty.pass.cpp @@ -10,14 +10,12 @@ // pop_back() more than the number of elements in a deque -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { std::deque q; diff --git a/libcxx/test/libcxx/containers/sequences/list/list.cons/db_copy.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.cons/debug.copy.pass.cpp rename from libcxx/test/libcxx/containers/sequences/list/list.cons/db_copy.pass.cpp rename to libcxx/test/libcxx/containers/sequences/list/list.cons/debug.copy.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/list/list.cons/db_copy.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/list/list.cons/debug.copy.pass.cpp @@ -10,17 +10,14 @@ // list(list&& c); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { std::list l1; l1.push_back(1); l1.push_back(2); l1.push_back(3); std::list::iterator i = l1.begin(); diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.erase_iter.end.pass.cpp rename from libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp rename to libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.erase_iter.end.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.erase_iter.end.pass.cpp @@ -10,17 +10,14 @@ // Call erase(const_iterator position) with end() -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { int a1[] = {1, 2, 3}; std::list l1(a1, a1+3); std::list::const_iterator i = l1.end(); diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/pop_back_db1.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.pop_back.empty.pass.cpp rename from libcxx/test/libcxx/containers/sequences/list/list.modifiers/pop_back_db1.pass.cpp rename to libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.pop_back.empty.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/pop_back_db1.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/assert.pop_back.empty.pass.cpp @@ -10,18 +10,15 @@ // void pop_back(); -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { int a[] = {1, 2, 3}; std::list c(a, a+3); c.pop_back(); diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/emplace_db1.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.emplace.pass.cpp rename from libcxx/test/libcxx/containers/sequences/list/list.modifiers/emplace_db1.pass.cpp rename to libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.emplace.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/emplace_db1.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.emplace.pass.cpp @@ -12,13 +12,11 @@ // UNSUPPORTED: c++03 // UNSUPPORTED: libcxx-no-debug-mode - // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" struct A { explicit A(int i, double d) { @@ -27,8 +25,7 @@ } }; -int main(int, char**) -{ +int main(int, char**) { std::list c1; std::list c2; TEST_LIBCPP_ASSERT_FAILURE(c1.emplace(c2.cbegin(), 2, 3.5), diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter.pass.cpp rename from libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp rename to libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter.pass.cpp @@ -10,17 +10,14 @@ // Call erase(const_iterator position) with iterator from another container -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { int a1[] = {1, 2, 3}; std::list l1(a1, a1+3); std::list l2(a1, a1+3); diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter_iter.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.erase.iter_iter.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// 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 + +#include "check_assertion.h" + +int main(int, char**) { + // First iterator from another container + { + int a1[] = {1, 2, 3}; + std::list l1(a1, a1+3); + std::list 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 l1(a1, a1+3); + std::list 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 l1(a1, a1+3); + std::list 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 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; +} diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_iter_iter.pass.cpp rename from libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.pass.cpp rename to libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_iter_iter.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_iter_iter_db1.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_iter_iter.pass.cpp @@ -11,24 +11,19 @@ // template // iterator insert(const_iterator position, Iter first, Iter last); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ - { - std::list v(100); - std::list v2(100); - int a[] = {1, 2, 3, 4, 5}; - TEST_LIBCPP_ASSERT_FAILURE(v.insert(v2.cbegin(), a, a + 5), - "list::insert(iterator, range) called with an iterator not referring to this list"); - } +int main(int, char**) { + std::list v(100); + std::list v2(100); + int a[] = {1, 2, 3, 4, 5}; + TEST_LIBCPP_ASSERT_FAILURE(v.insert(v2.cbegin(), a, a + 5), + "list::insert(iterator, range) called with an iterator not referring to this list"); - return 0; + return 0; } diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_rvalue.pass.cpp rename from libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp rename to libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_rvalue.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_rvalue_db1.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_rvalue.pass.cpp @@ -10,17 +10,14 @@ // iterator insert(const_iterator position, value_type&& x); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { std::list v1(3); std::list v2(3); TEST_LIBCPP_ASSERT_FAILURE(v1.insert(v2.begin(), 4), diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_size_value.pass.cpp rename from libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp rename to libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_size_value.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_size_value_db1.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_size_value.pass.cpp @@ -10,17 +10,14 @@ // iterator insert(const_iterator position, size_type n, const value_type& x); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { std::list c1(100); std::list c2; TEST_LIBCPP_ASSERT_FAILURE(c1.insert(c2.cbegin(), 5, 1), diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_value.pass.cpp rename from libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp rename to libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_value.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/insert_iter_value_db1.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/debug.insert.iter_value.pass.cpp @@ -10,17 +10,14 @@ // iterator insert(const_iterator position, const value_type& x); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { std::list v1(3); std::list v2(3); int i = 4; diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) -{ - int a1[] = {1, 2, 3}; - std::list l1(a1, a1+3); - std::list 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; -} diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) -{ - int a1[] = {1, 2, 3}; - std::list l1(a1, a1+3); - std::list 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; -} diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) -{ - int a1[] = {1, 2, 3}; - std::list l1(a1, a1+3); - std::list 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; -} diff --git a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) -{ - int a1[] = {1, 2, 3}; - std::list 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; -} diff --git a/libcxx/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list.pass.cpp rename from libcxx/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list.pass.cpp rename to libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list.pass.cpp @@ -10,23 +10,17 @@ // void splice(const_iterator position, list& x); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) -{ - { - std::list v1(3); - std::list v2(3); - TEST_LIBCPP_ASSERT_FAILURE(v1.splice(v2.begin(), v2), - "list::splice(iterator, list) called with an iterator not referring to this list"); - } +#include "check_assertion.h" +int main(int, char**) { + std::list v1(3); + std::list 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; } diff --git a/libcxx/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter.pass.cpp rename from libcxx/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter.pass.cpp rename to libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter.pass.cpp @@ -10,24 +10,19 @@ // void splice(const_iterator position, list& x, iterator i); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ - { - std::list v1(3); - std::list v2(3); - TEST_LIBCPP_ASSERT_FAILURE( - v1.splice(v1.begin(), v2, v1.begin()), - "list::splice(iterator, list, iterator) called with the second iterator not referring to the list argument"); - } +int main(int, char**) { + std::list v1(3); + std::list 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; } diff --git a/libcxx/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter_iter.pass.cpp b/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter_iter.pass.cpp rename from libcxx/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter_iter.pass.cpp rename to libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter_iter.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/list/list.ops/db_splice_pos_list_iter_iter.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/list/list.ops/debug.splice.pos_list_iter_iter.pass.cpp @@ -10,24 +10,19 @@ // void splice(const_iterator position, list& x, iterator first, iterator last); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ - { - std::list v1(3); - std::list v2(3); - TEST_LIBCPP_ASSERT_FAILURE( - v1.splice(v1.begin(), v2, v2.begin(), v1.end()), - "list::splice(iterator, list, iterator, iterator) called with third iterator not referring to the list argument"); - } +int main(int, char**) { + std::list v1(3); + std::list 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; } diff --git a/libcxx/test/libcxx/containers/sequences/vector/assert.back.empty.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.back.empty.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/sequences/vector/assert.back.empty.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Call back() on empty container. + +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 + +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef int T; + typedef std::vector > 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 C; + C c(1); + assert(c.back() == 0); + c.clear(); + TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector"); + } + + return 0; +} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_cback_2.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.cback.empty.pass.cpp rename from libcxx/test/libcxx/containers/sequences/vector/db_cback_2.pass.cpp rename to libcxx/test/libcxx/containers/sequences/vector/assert.cback.empty.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/vector/db_cback_2.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/assert.cback.empty.pass.cpp @@ -10,21 +10,28 @@ // Call back() on empty const container. -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "debug_macros.h" -#include "test_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef int T; - typedef std::vector > C; - const C c; - TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector"); + { + typedef int T; + typedef std::vector > C; + const C c; + TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector"); + } + + { + typedef int T; + typedef std::vector C; + const C c; + TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector"); + } return 0; } diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_cfront_2.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.cfront.empty.pass.cpp rename from libcxx/test/libcxx/containers/sequences/vector/db_cfront_2.pass.cpp rename to libcxx/test/libcxx/containers/sequences/vector/assert.cfront.empty.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/vector/db_cfront_2.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/assert.cfront.empty.pass.cpp @@ -10,21 +10,28 @@ // Call front() on empty const container. -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "debug_macros.h" -#include "test_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef int T; - typedef std::vector > C; - const C c; - TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector"); + { + typedef int T; + typedef std::vector > C; + const C c; + TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector"); + } + + { + typedef int T; + typedef std::vector C; + const C c; + TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector"); + } return 0; } diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.cindex.oob.pass.cpp rename from libcxx/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp rename to libcxx/test/libcxx/containers/sequences/vector/assert.cindex.oob.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/vector/db_cindex.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/assert.cindex.oob.pass.cpp @@ -10,23 +10,31 @@ // Index const vector out of bounds. -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include -#include "debug_macros.h" -#include "test_macros.h" +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef int T; + typedef std::vector > C; + const C c(1); + assert(c[0] == 0); + TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds"); + } -int main(int, char**) -{ + { typedef int T; typedef std::vector C; const C c(1); assert(c[0] == 0); TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds"); + } - return 0; + return 0; } diff --git a/libcxx/test/libcxx/containers/sequences/vector/assert.front.empty.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.front.empty.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/sequences/vector/assert.front.empty.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Call front() on empty container. + +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 + +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef int T; + typedef std::vector > 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 C; + C c(1); + assert(c.front() == 0); + c.clear(); + TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector"); + } + + return 0; +} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_index_2.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.index.oob.pass.cpp rename from libcxx/test/libcxx/containers/sequences/vector/db_index_2.pass.cpp rename to libcxx/test/libcxx/containers/sequences/vector/assert.index.oob.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/vector/db_index_2.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/assert.index.oob.pass.cpp @@ -10,23 +10,31 @@ // Index vector out of bounds. -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef int T; - typedef std::vector > 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 > 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 C; + C c(1); + assert(c[0] == 0); + TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds"); + } return 0; } diff --git a/libcxx/test/libcxx/containers/sequences/vector/pop_back_empty.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/assert.pop_back.empty.pass.cpp rename from libcxx/test/libcxx/containers/sequences/vector/pop_back_empty.pass.cpp rename to libcxx/test/libcxx/containers/sequences/vector/assert.pop_back.empty.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/vector/pop_back_empty.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/assert.pop_back.empty.pass.cpp @@ -10,14 +10,12 @@ // pop_back() more than the number of elements in a vector -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { std::vector v; diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_back.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_back.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_back.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call back() on empty container. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::vector C; - C c(1); - assert(c.back() == 0); - c.clear(); - TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_back_2.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_back_2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_back_2.pass.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call back() on empty container. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef int T; - typedef std::vector > C; - C c(1); - assert(c.back() == 0); - c.clear(); - TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_cback.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_cback.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_cback.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call back() on empty const container. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::vector C; - const C c; - TEST_LIBCPP_ASSERT_FAILURE(c.back(), "back() called on an empty vector"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_cfront.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call front() on empty const container. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::vector C; - const C c; - TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_cindex_2.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_cindex_2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_cindex_2.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Index const vector out of bounds. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "debug_macros.h" -#include "test_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef int T; - typedef std::vector > C; - const C c(1); - assert(c[0] == 0); - TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_front.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_front.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_front.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call front() on empty container. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::vector C; - C c(1); - assert(c.front() == 0); - c.clear(); - TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_front_2.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_front_2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_front_2.pass.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call front() on empty container. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef int T; - typedef std::vector > C; - C c(1); - assert(c.front() == 0); - c.clear(); - TEST_LIBCPP_ASSERT_FAILURE(c.front(), "front() called on an empty vector"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_index.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_index.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_index.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Index vector out of bounds. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::vector C; - C c(1); - assert(c[0] == 0); - TEST_LIBCPP_ASSERT_FAILURE(c[1], "vector[] index out of bounds"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_12.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_12.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_12.pass.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Add to iterator out of bounds. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef int T; - typedef std::vector > 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; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_14.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_14.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_14.pass.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef int T; - typedef std::vector > 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; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_15.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_15.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_15.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef int T; - typedef std::vector > C; - C c(1); - C::iterator i = c.end(); - TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_2.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Compare iterators from different containers with <. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::vector C; - C c1; - C c2; - TEST_LIBCPP_ASSERT_FAILURE(c1.begin() < c2.begin(), "Attempted to compare incomparable iterators"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_3.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Subtract iterators from different containers. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::vector C; - C c1; - C c2; - TEST_LIBCPP_ASSERT_FAILURE(c1.begin() - c2.begin(), "Attempted to subtract incompatible iterators"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_4.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Index iterator out of bounds. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::vector 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; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_5.pass.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Add to iterator out of bounds. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::vector 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; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_6.pass.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Decrement iterator prior to begin. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::vector 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; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_7.pass.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::vector 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; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_8.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::vector C; - C c(1); - C::iterator i = c.end(); - TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.add.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.add.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.add.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Add to iterator out of bounds. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef int T; + typedef std::vector 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 > 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; +} diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_9.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.compare.pass.cpp rename from libcxx/test/libcxx/containers/sequences/vector/db_iterators_9.pass.cpp rename to libcxx/test/libcxx/containers/sequences/vector/debug.iterator.compare.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_9.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.compare.pass.cpp @@ -10,22 +10,30 @@ // Compare iterators from different containers with <. -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef int T; - typedef std::vector > C; - C c1; - C c2; - TEST_LIBCPP_ASSERT_FAILURE(c1.begin() < c2.begin(), "Attempted to compare incomparable iterators"); + { + typedef int T; + typedef std::vector C; + C c1; + C c2; + TEST_LIBCPP_ASSERT_FAILURE(c1.begin() < c2.begin(), "Attempted to compare incomparable iterators"); + } + + { + typedef int T; + typedef std::vector > C; + C c1; + C c2; + TEST_LIBCPP_ASSERT_FAILURE(c1.begin() < c2.begin(), "Attempted to compare incomparable iterators"); + } return 0; } diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_13.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.decrement.pass.cpp rename from libcxx/test/libcxx/containers/sequences/vector/db_iterators_13.pass.cpp rename to libcxx/test/libcxx/containers/sequences/vector/debug.iterator.decrement.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_13.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.decrement.pass.cpp @@ -10,25 +10,35 @@ // Decrement iterator prior to begin. -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef int T; - typedef std::vector > 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 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 > 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; } diff --git a/libcxx/test/libcxx/containers/unord/unord.set/db_iterators_10.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.dereference.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.set/db_iterators_10.pass.cpp rename to libcxx/test/libcxx/containers/sequences/vector/debug.iterator.dereference.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.set/db_iterators_10.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.dereference.pass.cpp @@ -6,27 +6,34 @@ // //===----------------------------------------------------------------------===// -// +// // Dereference non-dereferenceable iterator. -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 -#include +#include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { + { + typedef int T; + typedef std::vector 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::unordered_set, std::equal_to, min_allocator> C; + typedef std::vector > C; C c(1); C::iterator i = c.end(); - TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container const_iterator"); + TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator"); + } - return 0; + return 0; } diff --git a/libcxx/test/libcxx/containers/unord/unord.set/db_iterators_9.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.increment.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.set/db_iterators_9.pass.cpp rename to libcxx/test/libcxx/containers/sequences/vector/debug.iterator.increment.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.set/db_iterators_9.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.increment.pass.cpp @@ -6,31 +6,39 @@ // //===----------------------------------------------------------------------===// -// +// // Increment iterator past end. -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 -#include +#include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { + { + typedef int T; + typedef std::vector 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::unordered_set, std::equal_to, min_allocator> C; - C c({42}); + typedef std::vector > C; + C c(1); C::iterator i = c.begin(); - assert(i != c.end()); ++i; assert(i == c.end()); - TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container const_iterator"); + TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator"); + } - return 0; + return 0; } diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_11.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.index.pass.cpp rename from libcxx/test/libcxx/containers/sequences/vector/db_iterators_11.pass.cpp rename to libcxx/test/libcxx/containers/sequences/vector/debug.iterator.index.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_11.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.index.pass.cpp @@ -10,24 +10,33 @@ // Index iterator out of bounds. -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef int T; - typedef std::vector > 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 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 > 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; } diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_10.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.subtract.pass.cpp rename from libcxx/test/libcxx/containers/sequences/vector/db_iterators_10.pass.cpp rename to libcxx/test/libcxx/containers/sequences/vector/debug.iterator.subtract.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_10.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/debug.iterator.subtract.pass.cpp @@ -10,22 +10,30 @@ // Subtract iterators from different containers. -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef int T; - typedef std::vector > C; - C c1; - C c2; - TEST_LIBCPP_ASSERT_FAILURE(c1.begin() - c2.begin(), "Attempted to subtract incompatible iterators"); + { + typedef int T; + typedef std::vector C; + C c1; + C c2; + TEST_LIBCPP_ASSERT_FAILURE(c1.begin() - c2.begin(), "Attempted to subtract incompatible iterators"); + } + + { + typedef int T; + typedef std::vector > C; + C c1; + C c2; + TEST_LIBCPP_ASSERT_FAILURE(c1.begin() - c2.begin(), "Attempted to subtract incompatible iterators"); + } return 0; } diff --git a/libcxx/test/libcxx/containers/unord/unord.map/db_bucket.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/assert.bucket.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.map/db_bucket.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.map/assert.bucket.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.map/db_bucket.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.map/assert.bucket.pass.cpp @@ -10,15 +10,13 @@ // size_type bucket(const key_type& __k) const; -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_map C; diff --git a/libcxx/test/libcxx/containers/unord/unord.map/bucket_size.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/assert.bucket_size.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.map/bucket_size.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.map/assert.bucket_size.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.map/bucket_size.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.map/assert.bucket_size.pass.cpp @@ -14,15 +14,13 @@ // size_type bucket_size(size_type n) const -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_map C; diff --git a/libcxx/test/libcxx/containers/unord/unord.map/max_load_factor.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/assert.max_load_factor.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.map/max_load_factor.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.map/assert.max_load_factor.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.map/max_load_factor.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.map/assert.max_load_factor.pass.cpp @@ -15,15 +15,13 @@ // float max_load_factor() const; // void max_load_factor(float mlf); -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_map C; diff --git a/libcxx/test/libcxx/containers/unord/unord.map/db_iterators_7.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/db_iterators_7.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/db_iterators_7.pass.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::unordered_map 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/db_iterators_8.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/db_iterators_8.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/db_iterators_8.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::unordered_map 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/db_iterators_9.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/db_iterators_9.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/db_iterators_9.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::unordered_map, std::equal_to, - min_allocator>> 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_10.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_10.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_10.pass.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::unordered_map, std::equal_to, - min_allocator>> 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_7.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_7.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_7.pass.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment local_iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::unordered_map 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_8.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_8.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_8.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::unordered_map 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_9.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_9.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/db_local_iterators_9.pass.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment local_iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::unordered_map, std::equal_to, - min_allocator>> 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/db_insert_hint_const_lvalue.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_const_lvalue.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.map/db_insert_hint_const_lvalue.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_const_lvalue.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.map/db_insert_hint_const_lvalue.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_const_lvalue.pass.cpp @@ -10,14 +10,13 @@ // iterator insert(const_iterator p, const value_type& x); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include +#include "check_assertion.h" #include "test_macros.h" -#include "debug_macros.h" int main(int, char**) { typedef std::unordered_map C; diff --git a/libcxx/test/libcxx/containers/unord/unord.map/db_insert_hint_rvalue.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_rvalue.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.map/db_insert_hint_rvalue.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_rvalue.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.map/db_insert_hint_rvalue.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.insert.hint_rvalue.pass.cpp @@ -15,13 +15,12 @@ // iterator insert(const_iterator p, P&& x); // UNSUPPORTED: libcxx-no-debug-mode - // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include +#include "check_assertion.h" #include "test_macros.h" -#include "debug_macros.h" int main(int, char**) { typedef std::unordered_map C; diff --git a/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.dereference.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.dereference.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef std::unordered_map 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, std::equal_to, + min_allocator>> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.increment.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.iterator.increment.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Increment iterator past end. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef std::unordered_map 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, std::equal_to, + min_allocator>> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.dereference.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.dereference.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef std::unordered_map 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, std::equal_to, + min_allocator>> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.increment.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.local_iterator.increment.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Increment local_iterator past end. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef std::unordered_map 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, std::equal_to, + min_allocator>> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/db_swap_1.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/debug.swap.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.map/db_swap_1.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.map/debug.swap.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.map/db_swap_1.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.map/debug.swap.pass.cpp @@ -14,14 +14,12 @@ // void swap(unordered_map& x, unordered_map& y); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::pair P; diff --git a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Call erase(const_iterator position) with invalid iterators + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include + +#include "check_assertion.h" + +int main(int, char**) { + // With end() + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_map l1(a1, a1+3); + std::unordered_map::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 P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_map l1(a1, a1+3); + std::unordered_map l2(a1, a1+3); + std::unordered_map::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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter_iter.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/debug.erase.iter_iter.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// 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 + +#include "check_assertion.h" + +int main(int, char**) { + // First iterator from a different container + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_map l1(a1, a1+3); + std::unordered_map 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 P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_map l1(a1, a1+3); + std::unordered_map 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 P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_map l1(a1, a1+3); + std::unordered_map 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 P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_map 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_db1.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_db1.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_db1.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call erase(const_iterator position) with end() - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::pair P; - P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; - std::unordered_map l1(a1, a1+3); - std::unordered_map::const_iterator i = l1.end(); - TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), - "unordered container erase(iterator) called with a non-dereferenceable iterator"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_db2.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_db2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_db2.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call erase(const_iterator position) with iterator from another container - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::pair P; - P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; - std::unordered_map l1(a1, a1+3); - std::unordered_map l2(a1, a1+3); - std::unordered_map::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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db1.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db1.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db1.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::pair P; - P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; - std::unordered_map l1(a1, a1+3); - std::unordered_map 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db2.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db2.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::pair P; - P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; - std::unordered_map l1(a1, a1+3); - std::unordered_map 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db3.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db3.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db3.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::pair P; - P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; - std::unordered_map l1(a1, a1+3); - std::unordered_map 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db4.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db4.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db4.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::pair P; - P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; - std::unordered_map 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/bucket.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.multimap/bucket.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.multimap/bucket.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket.pass.cpp @@ -14,15 +14,13 @@ // size_type bucket(const key_type& __k) const; -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_multimap C; diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/bucket_size.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket_size.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.multimap/bucket_size.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket_size.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.multimap/bucket_size.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.multimap/assert.bucket_size.pass.cpp @@ -14,15 +14,13 @@ // size_type bucket_size(size_type n) const -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_multimap C; diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/max_load_factor.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/assert.max_load_factor.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.multimap/max_load_factor.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.multimap/assert.max_load_factor.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.multimap/max_load_factor.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.multimap/assert.max_load_factor.pass.cpp @@ -15,15 +15,13 @@ // float max_load_factor() const; // void max_load_factor(float mlf); -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_multimap C; diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/db_iterators_10.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/db_iterators_10.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/db_iterators_10.pass.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::unordered_multimap, std::equal_to, - min_allocator>> 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/db_iterators_7.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/db_iterators_7.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/db_iterators_7.pass.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::unordered_multimap 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/db_iterators_8.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/db_iterators_8.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/db_iterators_8.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::unordered_multimap 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/db_local_iterators_10.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/db_local_iterators_10.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/db_local_iterators_10.pass.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::unordered_multimap, std::equal_to, - min_allocator>> 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment local_iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::unordered_multimap 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::unordered_multimap 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/db_local_iterators_9.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/db_local_iterators_9.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/db_local_iterators_9.pass.cpp +++ /dev/null @@ -1,39 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment local_iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::unordered_multimap, std::equal_to, - min_allocator>> 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/db_insert_hint_const_lvalue.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_const_lvalue.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.multimap/db_insert_hint_const_lvalue.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_const_lvalue.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.multimap/db_insert_hint_const_lvalue.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_const_lvalue.pass.cpp @@ -10,14 +10,12 @@ // iterator insert(const_iterator p, const value_type& x); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_multimap C; diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/db_insert_hint_rvalue.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_rvalue.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.multimap/db_insert_hint_rvalue.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_rvalue.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.multimap/db_insert_hint_rvalue.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.insert.hint_rvalue.pass.cpp @@ -15,13 +15,11 @@ // iterator insert(const_iterator p, P&& x); // UNSUPPORTED: libcxx-no-debug-mode - // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_multimap C; diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.dereference.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.dereference.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef std::unordered_multimap 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, std::equal_to, + min_allocator>> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.increment.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.iterator.increment.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Increment iterator past end. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef std::unordered_multimap 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, std::equal_to, + min_allocator>> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.dereference.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.dereference.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef std::unordered_multimap 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, std::equal_to, + min_allocator>> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.increment.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.local_iterator.increment.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Increment local_iterator past end. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef std::unordered_multimap 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, std::equal_to, + min_allocator>> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/db_swap_1.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.swap.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.multimap/db_swap_1.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.multimap/debug.swap.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.multimap/db_swap_1.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.multimap/debug.swap.pass.cpp @@ -14,17 +14,14 @@ // void swap(unordered_multimap& x, unordered_multimap& y); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { typedef std::pair 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)}; diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Call erase(const_iterator position) with invalid iterators + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include + +#include "check_assertion.h" + +int main(int, char**) { + // With end() + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_multimap l1(a1, a1+3); + std::unordered_multimap::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 P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_multimap l1(a1, a1+3); + std::unordered_multimap l2(a1, a1+3); + std::unordered_multimap::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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter_iter.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/debug.erase.iter_iter.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// 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 + +#include "check_assertion.h" + +int main(int, char**) { + // With first iterator from another container + { + typedef std::pair P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_multimap l1(a1, a1+3); + std::unordered_multimap 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 P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_multimap l1(a1, a1+3); + std::unordered_multimap 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 P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_multimap l1(a1, a1+3); + std::unordered_multimap 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 P; + P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; + std::unordered_multimap 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call erase(const_iterator position) with end() - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::pair P; - P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; - std::unordered_multimap l1(a1, a1+3); - std::unordered_multimap::const_iterator i = l1.end(); - TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), - "unordered container erase(iterator) called with a non-dereferenceable iterator"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call erase(const_iterator position) with iterator from another container - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::pair P; - P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; - std::unordered_multimap l1(a1, a1+3); - std::unordered_multimap l2(a1, a1+3); - std::unordered_multimap::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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::pair P; - P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; - std::unordered_multimap l1(a1, a1+3); - std::unordered_multimap 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::pair P; - P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; - std::unordered_multimap l1(a1, a1+3); - std::unordered_multimap 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::pair P; - P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; - std::unordered_multimap l1(a1, a1+3); - std::unordered_multimap 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef std::pair P; - P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; - std::unordered_multimap 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/bucket.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.multiset/bucket.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.multiset/bucket.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket.pass.cpp @@ -14,14 +14,12 @@ // size_type bucket(const key_type& __k) const; -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_multiset C; diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/bucket_size.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket_size.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.multiset/bucket_size.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket_size.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.multiset/bucket_size.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.multiset/assert.bucket_size.pass.cpp @@ -14,14 +14,12 @@ // size_type bucket_size(size_type n) const -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_multiset C; diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/max_load_factor.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/assert.max_load_factor.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.multiset/max_load_factor.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.multiset/assert.max_load_factor.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.multiset/max_load_factor.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.multiset/assert.max_load_factor.pass.cpp @@ -15,14 +15,12 @@ // float max_load_factor() const; // void max_load_factor(float mlf); -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_multiset C; diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/db_iterators_10.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/db_iterators_10.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/db_iterators_10.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_multiset, std::equal_to, min_allocator> 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/db_iterators_7.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/db_iterators_7.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/db_iterators_7.pass.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_multiset 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/db_iterators_8.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/db_iterators_8.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/db_iterators_8.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_multiset 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/db_iterators_9.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/db_iterators_9.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/db_iterators_9.pass.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_multiset, std::equal_to, min_allocator> 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/db_local_iterators_10.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/db_local_iterators_10.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/db_local_iterators_10.pass.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_multiset, std::equal_to, min_allocator> 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment local_iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_multiset 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_multiset 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/db_local_iterators_9.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/db_local_iterators_9.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/db_local_iterators_9.pass.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment local_iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_multiset, std::equal_to, min_allocator> 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Call erase(const_iterator position) with invalid iterators + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include + +#include "check_assertion.h" + +int main(int, char**) { + // With end() + { + int a1[] = {1, 2, 3}; + std::unordered_multiset l1(a1, a1+3); + std::unordered_multiset::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 l1(a1, a1+3); + std::unordered_multiset l2(a1, a1+3); + std::unordered_multiset::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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter_iter.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.erase.iter_iter.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// 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 + +#include "check_assertion.h" + +int main(int, char**) { + // With first iterator from another container + { + int a1[] = {1, 2, 3}; + std::unordered_multiset l1(a1, a1+3); + std::unordered_multiset 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 l1(a1, a1+3); + std::unordered_multiset 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 l1(a1, a1+3); + std::unordered_multiset 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 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/db_insert_hint_const_lvalue.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.insert.hint_const_lvalue.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.multiset/db_insert_hint_const_lvalue.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.multiset/debug.insert.hint_const_lvalue.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.multiset/db_insert_hint_const_lvalue.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.insert.hint_const_lvalue.pass.cpp @@ -10,14 +10,12 @@ // iterator insert(const_iterator p, const value_type& x); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_multiset C; diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.dereference.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.dereference.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef int T; + typedef std::unordered_multiset 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, std::equal_to, min_allocator> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.increment.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.iterator.increment.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Increment iterator past end. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef int T; + typedef std::unordered_multiset 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, std::equal_to, min_allocator> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.dereference.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.dereference.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef int T; + typedef std::unordered_multiset 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, std::equal_to, min_allocator> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.increment.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.local_iterator.increment.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Increment local_iterator past end. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef int T; + typedef std::unordered_multiset 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, std::equal_to, min_allocator> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/db_swap_1.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.swap.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.multiset/db_swap_1.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.multiset/debug.swap.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.multiset/db_swap_1.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.multiset/debug.swap.pass.cpp @@ -14,14 +14,12 @@ // void swap(unordered_multiset& x, unordered_multiset& y); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { int a1[] = {1, 3, 7, 9, 10}; diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_db1.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_db1.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_db1.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call erase(const_iterator position) with end() - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - int a1[] = {1, 2, 3}; - std::unordered_multiset l1(a1, a1+3); - std::unordered_multiset::const_iterator i = l1.end(); - TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), - "unordered container erase(iterator) called with a non-dereferenceable iterator"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_db2.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_db2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_db2.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call erase(const_iterator position) with iterator from another container - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - int a1[] = {1, 2, 3}; - std::unordered_multiset l1(a1, a1+3); - std::unordered_multiset l2(a1, a1+3); - std::unordered_multiset::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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - int a1[] = {1, 2, 3}; - std::unordered_multiset l1(a1, a1+3); - std::unordered_multiset 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - int a1[] = {1, 2, 3}; - std::unordered_multiset l1(a1, a1+3); - std::unordered_multiset 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - int a1[] = {1, 2, 3}; - std::unordered_multiset l1(a1, a1+3); - std::unordered_multiset 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - int a1[] = {1, 2, 3}; - std::unordered_multiset 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/bucket.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/assert.bucket.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.set/bucket.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.set/assert.bucket.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.set/bucket.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.set/assert.bucket.pass.cpp @@ -14,14 +14,12 @@ // size_type bucket(const key_type& __k) const; -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_set C; diff --git a/libcxx/test/libcxx/containers/unord/unord.set/bucket_size.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/assert.bucket_size.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.set/bucket_size.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.set/assert.bucket_size.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.set/bucket_size.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.set/assert.bucket_size.pass.cpp @@ -14,14 +14,12 @@ // size_type bucket_size(size_type n) const -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_set C; diff --git a/libcxx/test/libcxx/containers/unord/unord.set/max_load_factor.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/assert.max_load_factor.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.set/max_load_factor.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.set/assert.max_load_factor.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.set/max_load_factor.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.set/assert.max_load_factor.pass.cpp @@ -15,14 +15,12 @@ // float max_load_factor() const; // void max_load_factor(float mlf); -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_set C; diff --git a/libcxx/test/libcxx/containers/unord/unord.set/db_iterators_7.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/db_iterators_7.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/db_iterators_7.pass.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_set 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/db_iterators_8.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/db_iterators_8.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/db_iterators_8.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_set 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/db_local_iterators_10.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/db_local_iterators_10.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/db_local_iterators_10.pass.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_set, std::equal_to, min_allocator> 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/db_local_iterators_7.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/db_local_iterators_7.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/db_local_iterators_7.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment local_iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_set 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/db_local_iterators_8.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/db_local_iterators_8.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/db_local_iterators_8.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_set 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/db_local_iterators_9.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/db_local_iterators_9.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/db_local_iterators_9.pass.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment local_iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef int T; - typedef std::unordered_set, std::equal_to, min_allocator> 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Call erase(const_iterator position) with invalid iterators + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include + +#include "check_assertion.h" + +int main(int, char**) { + // With end() + { + int a1[] = {1, 2, 3}; + std::unordered_set l1(a1, a1+3); + std::unordered_set::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 l1(a1, a1+3); + std::unordered_set l2(a1, a1+3); + std::unordered_set::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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter_iter.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.erase.iter_iter.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// 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 + +#include "check_assertion.h" + +int main(int, char**) { + // With first iterator from another container + { + int a1[] = {1, 2, 3}; + std::unordered_set l1(a1, a1+3); + std::unordered_set 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 l1(a1, a1+3); + std::unordered_set 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 l1(a1, a1+3); + std::unordered_set 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 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/db_insert_hint_const_lvalue.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.insert.hint_const_lvalue.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.set/db_insert_hint_const_lvalue.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.set/debug.insert.hint_const_lvalue.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.set/db_insert_hint_const_lvalue.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.insert.hint_const_lvalue.pass.cpp @@ -10,14 +10,12 @@ // iterator insert(const_iterator p, const value_type& x); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { typedef std::unordered_set C; diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.dereference.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.dereference.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef int T; + typedef std::unordered_set 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, std::equal_to, min_allocator> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.increment.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.iterator.increment.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Increment iterator past end. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef int T; + typedef std::unordered_set 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, std::equal_to, min_allocator> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.dereference.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.dereference.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.dereference.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Dereference non-dereferenceable iterator. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef int T; + typedef std::unordered_set 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, std::equal_to, min_allocator> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.increment.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.increment.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.local_iterator.increment.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Increment local_iterator past end. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include + +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef int T; + typedef std::unordered_set 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, std::equal_to, min_allocator> 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; +} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/db_swap_1.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/debug.swap.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.set/db_swap_1.pass.cpp rename to libcxx/test/libcxx/containers/unord/unord.set/debug.swap.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.set/db_swap_1.pass.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.set/debug.swap.pass.cpp @@ -14,14 +14,12 @@ // void swap(unordered_set& x, unordered_set& y); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" int main(int, char**) { int a1[] = {1, 3, 7, 9, 10}; diff --git a/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_db1.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_db1.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_db1.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call erase(const_iterator position) with end() - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - int a1[] = {1, 2, 3}; - std::unordered_set l1(a1, a1+3); - std::unordered_set::const_iterator i = l1.end(); - TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), - "unordered container erase(iterator) called with a non-dereferenceable iterator"); - - return 0; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_db2.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_db2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_db2.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call erase(const_iterator position) with iterator from another container - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - int a1[] = {1, 2, 3}; - std::unordered_set l1(a1, a1+3); - std::unordered_set l2(a1, a1+3); - std::unordered_set::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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - int a1[] = {1, 2, 3}; - std::unordered_set l1(a1, a1+3); - std::unordered_set 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - int a1[] = {1, 2, 3}; - std::unordered_set l1(a1, a1+3); - std::unordered_set 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - int a1[] = {1, 2, 3}; - std::unordered_set l1(a1, a1+3); - std::unordered_set 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; -} diff --git a/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp b/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - int a1[] = {1, 2, 3}; - std::unordered_set 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; -} diff --git a/libcxx/test/libcxx/debug/debug_helper_test.pass.cpp b/libcxx/test/libcxx/debug/check_assertion_test.pass.cpp rename from libcxx/test/libcxx/debug/debug_helper_test.pass.cpp rename to libcxx/test/libcxx/debug/check_assertion_test.pass.cpp --- a/libcxx/test/libcxx/debug/debug_helper_test.pass.cpp +++ b/libcxx/test/libcxx/debug/check_assertion_test.pass.cpp @@ -6,18 +6,14 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: windows - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 -// UNSUPPORTED: libcxx-no-debug-mode #include <__debug> -#include "debug_mode_helper.h" - #include -#include "test_macros.h" +#include "check_assertion.h" +#include "test_macros.h" template inline bool TestDeathTest(const char* stmt, Func&& func, DeathTest::ResultKind ExpectResult, DebugInfoMatcher Matcher = AnyMatcher) { @@ -58,8 +54,7 @@ TEST_DEATH_TEST(DeathTest::RK_Unknown, std::exit(13)); } -int main(int, char**) -{ +int main(int, char**) { test_no_match_found(); test_did_not_die(); test_unknown(); diff --git a/libcxx/test/libcxx/debug/containers/db_sequence_container_iterators.multithread.pass.cpp b/libcxx/test/libcxx/debug/containers.multithread.pass.cpp rename from libcxx/test/libcxx/debug/containers/db_sequence_container_iterators.multithread.pass.cpp rename to libcxx/test/libcxx/debug/containers.multithread.pass.cpp --- a/libcxx/test/libcxx/debug/containers/db_sequence_container_iterators.multithread.pass.cpp +++ b/libcxx/test/libcxx/debug/containers.multithread.pass.cpp @@ -10,10 +10,10 @@ // UNSUPPORTED: windows // UNSUPPORTED: libcpp-has-no-threads -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 // UNSUPPORTED: libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 -// test multihtreaded container debugging +// test multithreaded container debugging #include #include @@ -21,10 +21,6 @@ #include #include #include -#include "container_debug_tests.h" - -#include "test_macros.h" - template Container makeContainer(int size) { diff --git a/libcxx/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp b/libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp rename from libcxx/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp rename to libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp --- a/libcxx/test/libcxx/debug/containers/db_associative_container_tests.pass.cpp +++ b/libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp @@ -9,8 +9,8 @@ // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: windows -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 // UNSUPPORTED: libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 // test container debugging @@ -18,9 +18,9 @@ #include #include #include +#include "check_assertion.h" #include "container_debug_tests.h" #include "test_macros.h" -#include "debug_mode_helper.h" using namespace IteratorDebugChecks; diff --git a/libcxx/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp b/libcxx/test/libcxx/debug/containers/sequence_container_iterators.pass.cpp rename from libcxx/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp rename to libcxx/test/libcxx/debug/containers/sequence_container_iterators.pass.cpp --- a/libcxx/test/libcxx/debug/containers/db_sequence_container_iterators.pass.cpp +++ b/libcxx/test/libcxx/debug/containers/sequence_container_iterators.pass.cpp @@ -9,8 +9,8 @@ // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: windows -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 // UNSUPPORTED: libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 // test container debugging @@ -18,9 +18,9 @@ #include #include #include +#include "check_assertion.h" #include "container_debug_tests.h" #include "test_macros.h" -#include "debug_mode_helper.h" using namespace IteratorDebugChecks; diff --git a/libcxx/test/libcxx/debug/containers/db_string.pass.cpp b/libcxx/test/libcxx/debug/containers/string.pass.cpp rename from libcxx/test/libcxx/debug/containers/db_string.pass.cpp rename to libcxx/test/libcxx/debug/containers/string.pass.cpp --- a/libcxx/test/libcxx/debug/containers/db_string.pass.cpp +++ b/libcxx/test/libcxx/debug/containers/string.pass.cpp @@ -9,8 +9,8 @@ // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: windows -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 // UNSUPPORTED: libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 // test container debugging @@ -18,8 +18,8 @@ #include #include "test_macros.h" +#include "check_assertion.h" #include "container_debug_tests.h" -#include "debug_mode_helper.h" using namespace IteratorDebugChecks; diff --git a/libcxx/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp b/libcxx/test/libcxx/debug/containers/unord_containers.pass.cpp rename from libcxx/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp rename to libcxx/test/libcxx/debug/containers/unord_containers.pass.cpp --- a/libcxx/test/libcxx/debug/containers/db_unord_container_tests.pass.cpp +++ b/libcxx/test/libcxx/debug/containers/unord_containers.pass.cpp @@ -9,8 +9,8 @@ // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: windows -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 // UNSUPPORTED: libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 // test container debugging @@ -18,9 +18,9 @@ #include #include #include +#include "check_assertion.h" #include "container_debug_tests.h" #include "test_macros.h" -#include "debug_mode_helper.h" using namespace IteratorDebugChecks; diff --git a/libcxx/test/libcxx/debug/db_string_view.pass.cpp b/libcxx/test/libcxx/debug/db_string_view.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/debug/db_string_view.pass.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14 -// UNSUPPORTED: windows - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 -// UNSUPPORTED: libcxx-no-debug-mode - -// test container debugging - -#include - -#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(0))); - { - std::string_view v; - EXPECT_DEATH(((void)(v == nullp))); - EXPECT_DEATH(((void)(nullp == v))); - } -} - -int main(int, char**) { - test_null_argument(); - - return 0; -} diff --git a/libcxx/test/libcxx/debug/debug_abort.pass.cpp b/libcxx/test/libcxx/debug/debug_abort.pass.cpp --- a/libcxx/test/libcxx/debug/debug_abort.pass.cpp +++ b/libcxx/test/libcxx/debug/debug_abort.pass.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0 // UNSUPPORTED: libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 // Test that the default debug handler aborts the program. diff --git a/libcxx/test/libcxx/debug/debug_register.pass.cpp b/libcxx/test/libcxx/debug/register_debug_handler.pass.cpp rename from libcxx/test/libcxx/debug/debug_register.pass.cpp rename to libcxx/test/libcxx/debug/register_debug_handler.pass.cpp diff --git a/libcxx/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/deallocate.assert.pass.cpp b/libcxx/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/assert.deallocate.pass.cpp rename from libcxx/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/deallocate.assert.pass.cpp rename to libcxx/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/assert.deallocate.pass.cpp --- a/libcxx/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/deallocate.assert.pass.cpp +++ b/libcxx/test/libcxx/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/assert.deallocate.pass.cpp @@ -6,31 +6,25 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 - // // template class polymorphic_allocator // T* polymorphic_allocator::deallocate(T*, size_t size) -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include #include +#include "check_assertion.h" #include "test_memory_resource.h" -#include "test_macros.h" -#include "debug_macros.h" - namespace ex = std::experimental::pmr; -int main(int, char**) -{ +int main(int, char**) { using Alloc = ex::polymorphic_allocator; using Traits = std::allocator_traits; NullResource R; diff --git a/libcxx/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/deallocate.assert.pass.cpp b/libcxx/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/assert.deallocate.pass.cpp rename from libcxx/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/deallocate.assert.pass.cpp rename to libcxx/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/assert.deallocate.pass.cpp --- a/libcxx/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/deallocate.assert.pass.cpp +++ b/libcxx/test/libcxx/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/assert.deallocate.pass.cpp @@ -6,31 +6,25 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 - // // template class polymorphic_allocator // T* polymorphic_allocator::deallocate(T*, size_t size) -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include #include +#include "check_assertion.h" #include "test_memory_resource.h" -#include "test_macros.h" -#include "debug_macros.h" - namespace ex = std::experimental::pmr; -int main(int, char**) -{ +int main(int, char**) { using Alloc = NullAllocator; AllocController P; diff --git a/libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/iterator_db.pass.cpp b/libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/assert.iterator.pass.cpp rename from libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/iterator_db.pass.cpp rename to libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/assert.iterator.pass.cpp --- a/libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/iterator_db.pass.cpp +++ b/libcxx/test/libcxx/input.output/filesystems/class.path/path.itr/assert.iterator.pass.cpp @@ -6,11 +6,8 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: windows -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 // @@ -21,33 +18,28 @@ #include #include -#include "test_macros.h" -#include "debug_mode_helper.h" +#include "check_assertion.h" int main(int, char**) { - using namespace fs; // Test incrementing/decrementing a singular iterator { - path::iterator singular; - EXPECT_DEATH( ++singular ); - EXPECT_DEATH( --singular ); + fs::path::iterator singular; + TEST_LIBCPP_ASSERT_FAILURE(++singular, "attempting to increment a singular iterator"); + TEST_LIBCPP_ASSERT_FAILURE(--singular, "attempting to decrement a singular iterator"); } - // Test decrementing the begin iterator + + // Test incrementing the end iterator { - path p("foo/bar"); + fs::path p("foo/bar"); auto it = p.begin(); - ++it; - ++it; - EXPECT_DEATH( ++it ); + TEST_LIBCPP_ASSERT_FAILURE(--it, "attempting to decrement the begin iterator"); } + // Test incrementing the end iterator { - path p("foo/bar"); + fs::path p("foo/bar"); auto it = p.end(); - EXPECT_DEATH( ++it ); - --it; - --it; - EXPECT_DEATH( --it ); + TEST_LIBCPP_ASSERT_FAILURE(++it, "attempting to increment the end iterator"); } return 0; diff --git a/libcxx/test/libcxx/iterators/advance.debug1.pass.cpp b/libcxx/test/libcxx/iterators/assert.advance.pass.cpp rename from libcxx/test/libcxx/iterators/advance.debug1.pass.cpp rename to libcxx/test/libcxx/iterators/assert.advance.pass.cpp --- a/libcxx/test/libcxx/iterators/advance.debug1.pass.cpp +++ b/libcxx/test/libcxx/iterators/assert.advance.pass.cpp @@ -6,23 +6,19 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: windows -// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0 -// UNSUPPORTED: libcxx-no-debug-mode +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 // // Call advance(non-bidi iterator, -1) #include -#include "test_macros.h" -#include "debug_mode_helper.h" +#include "check_assertion.h" #include "test_iterators.h" -int main(int, char**) -{ +int main(int, char**) { int a[] = {1, 2, 3}; bidirectional_iterator bidi(a+1); @@ -33,7 +29,7 @@ forward_iterator it(a+1); std::advance(it, 1); // should work fine std::advance(it, 0); // should work fine - EXPECT_DEATH( std::advance(it, -1) ); // can't go backwards on a FwdIter + TEST_LIBCPP_ASSERT_FAILURE(std::advance(it, -1), "Attempt to advance(it, n) with negative n on a non-bidirectional iterator"); - return 0; + return 0; } diff --git a/libcxx/test/libcxx/iterators/next.debug1.pass.cpp b/libcxx/test/libcxx/iterators/assert.next.pass.cpp rename from libcxx/test/libcxx/iterators/next.debug1.pass.cpp rename to libcxx/test/libcxx/iterators/assert.next.pass.cpp --- a/libcxx/test/libcxx/iterators/next.debug1.pass.cpp +++ b/libcxx/test/libcxx/iterators/assert.next.pass.cpp @@ -6,30 +6,24 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: windows -// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0 -// UNSUPPORTED: libcxx-no-debug-mode +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 // // Call next(non-bidi iterator, -1) #include -#include "test_macros.h" -#include "debug_mode_helper.h" +#include "check_assertion.h" #include "test_iterators.h" -int main(int, char**) -{ +int main(int, char**) { int a[] = {1, 2, 3}; - - forward_iterator it(a+1); std::next(it, 1); // should work fine std::next(it, 0); // should work fine - EXPECT_DEATH( std::next(it, -1) ); // can't go backwards on a FwdIter + TEST_LIBCPP_ASSERT_FAILURE(std::next(it, -1), "Attempt to next(it, n) with negative n on a non-bidirectional iterator"); - return 0; + return 0; } diff --git a/libcxx/test/libcxx/iterators/prev.debug1.pass.cpp b/libcxx/test/libcxx/iterators/assert.prev.pass.cpp rename from libcxx/test/libcxx/iterators/prev.debug1.pass.cpp rename to libcxx/test/libcxx/iterators/assert.prev.pass.cpp --- a/libcxx/test/libcxx/iterators/prev.debug1.pass.cpp +++ b/libcxx/test/libcxx/iterators/assert.prev.pass.cpp @@ -6,23 +6,19 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: windows -// ADDITIONAL_COMPILE_FLAGS: -Wno-macro-redefined -D_LIBCPP_DEBUG=0 -// UNSUPPORTED: libcxx-no-debug-mode +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 // // Call prev(forward_iterator, -1) #include -#include "test_macros.h" -#include "debug_mode_helper.h" +#include "check_assertion.h" #include "test_iterators.h" -int main(int, char**) -{ +int main(int, char**) { int a[] = {1, 2, 3}; bidirectional_iterator bidi(a+1); @@ -33,7 +29,7 @@ forward_iterator it(a+1); std::prev(it, -1); // should work fine std::prev(it, 0); // should work fine - EXPECT_DEATH( std::prev(it, 1) ); // can't go backwards on a FwdIter + TEST_LIBCPP_ASSERT_FAILURE(std::prev(it, 1), "Attempt to prev(it, n) with a positive n on a non-bidirectional iterator"); - return 0; + return 0; } diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/db_back_2.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.access/db_back_2.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.access/db_back_2.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp @@ -10,23 +10,25 @@ // Call back() on empty container. -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef std::basic_string, min_allocator > S; - S s(1, '\0'); - assert(s.back() == 0); - s.clear(); - TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty"); - - return 0; + { + std::string s; + TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty"); + } + + { + typedef std::basic_string, min_allocator > S; + S s; + TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty"); + } + + return 0; } diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/db_cback_2.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.access/db_cback_2.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.access/db_cback_2.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp @@ -10,20 +10,25 @@ // Call back() on empty const container. -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "debug_macros.h" -#include "test_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef std::basic_string, min_allocator > S; - const S s; - TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty"); - - return 0; + { + std::string const s; + TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty"); + } + + { + typedef std::basic_string, min_allocator > S; + const S s; + TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty"); + } + + return 0; } diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/db_cfront_2.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.access/db_cfront_2.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.access/db_cfront_2.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp @@ -10,20 +10,26 @@ // Call front() on empty const container. -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "debug_macros.h" -#include "test_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef std::basic_string, min_allocator > S; - const S s; - TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty"); + { + typedef std::string S; + const S s; + TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty"); + } + + { + typedef std::basic_string, min_allocator > S; + const S s; + TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty"); + } return 0; } diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/db_cindex_2.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.access/db_cindex_2.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.access/db_cindex_2.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp @@ -10,22 +10,29 @@ // Index const string out of bounds. -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef std::basic_string, min_allocator > S; - const S s; - assert(s[0] == 0); - TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds"); + { + typedef std::basic_string, min_allocator > 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; } diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/db_front_2.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.access/db_front_2.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.access/db_front_2.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp @@ -10,23 +10,27 @@ // Call front() on empty container. -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef std::basic_string, min_allocator > S; - S s(1, '\0'); - assert(s.front() == 0); - s.clear(); - TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty"); + { + typedef std::string S; + S s; + TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty"); + } + + { + typedef std::basic_string, min_allocator > S; + S s; + TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty"); + } return 0; } diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/db_index_2.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.access/db_index_2.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.access/db_index_2.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp @@ -10,22 +10,29 @@ // Index string out of bounds. -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef std::basic_string, min_allocator > S; - S s; - assert(s[0] == 0); - TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds"); + { + typedef std::string S; + S s; + assert(s[0] == 0); + TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds"); + } + + { + typedef std::basic_string, min_allocator > S; + S s; + assert(s[0] == 0); + TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds"); + } return 0; } diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/back.const.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/back.const.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.access/back.const.pass.cpp +++ /dev/null @@ -1,26 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// const charT& back() const; - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/back.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/back.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.access/back.pass.cpp +++ /dev/null @@ -1,26 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// charT& back(); - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/db_back.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/db_back.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.access/db_back.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call back() on empty container. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/db_cback.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/db_cback.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.access/db_cback.pass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call back() on empty const container. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/db_cfront.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/db_cfront.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.access/db_cfront.pass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call front() on empty const container. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/db_cindex.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/db_cindex.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.access/db_cindex.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Index const string out of bounds. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/db_front.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/db_front.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.access/db_front.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call front() on empty container. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/db_index.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/db_index.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.access/db_index.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Index string out of bounds. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/front.const.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/front.const.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.access/front.const.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// const charT& front() const; - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/front.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/front.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.access/front.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// charT& front(); - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/index.const.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/index.const.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.access/index.const.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// const_reference operator[](size_type pos) const; - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/index.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/index.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.access/index.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// reference operator[](size_type pos); - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_10.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_10.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_10.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Subtract iterators from different containers with <. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::basic_string, min_allocator > S; - S s1; - S s2; - TEST_LIBCPP_ASSERT_FAILURE(s1.begin() - s2.begin(), "Attempted to subtract incompatible iterators"); - - return 0; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_12.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_12.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_12.pass.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Add to iterator out of bounds. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::basic_string, min_allocator > 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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_14.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_14.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_14.pass.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::basic_string, min_allocator > 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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_15.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_15.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_15.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::basic_string, min_allocator > C; - C c(1, '\0'); - C::iterator i = c.end(); - TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator"); - - return 0; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_2.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_2.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Compare iterators from different containers with <. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_3.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_3.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_3.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Subtract iterators from different containers with <. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_4.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_4.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_4.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Index iterator out of bounds. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_5.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_5.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_5.pass.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Add to iterator out of bounds. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_6.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_6.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_6.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Decrement iterator prior to begin. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_7.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_7.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_7.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Increment iterator past end. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_8.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_8.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_8.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Dereference non-dereferenceable iterator. - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// Add to iterator out of bounds. + +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 + +#include +#include + +#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, min_allocator > 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; +} diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_9.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_9.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_9.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp @@ -10,21 +10,28 @@ // Compare iterators from different containers with <. -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef std::basic_string, min_allocator > S; - S s1; - S s2; - TEST_LIBCPP_ASSERT_FAILURE(s1.begin() < s2.begin(), "Attempted to compare incomparable iterators"); + { + 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, min_allocator > S; + S s1; + S s2; + TEST_LIBCPP_ASSERT_FAILURE(s1.begin() < s2.begin(), "Attempted to compare incomparable iterators"); + } return 0; } diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_13.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_13.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_13.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp @@ -10,24 +10,33 @@ // Decrement iterator prior to begin. -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef std::basic_string, min_allocator > 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::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, min_allocator > 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; } diff --git a/libcxx/test/libcxx/containers/unord/unord.map/db_iterators_10.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.map/db_iterators_10.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.map/db_iterators_10.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp @@ -6,29 +6,32 @@ // //===----------------------------------------------------------------------===// -// +// // Dereference non-dereferenceable iterator. -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 -#include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef std::unordered_map, std::equal_to, - min_allocator>> C; - C c; - c.insert(std::make_pair(1, "one")); + { + 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, min_allocator > C; + C c(1, '\0'); C::iterator i = c.end(); - TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container iterator"); + TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator"); + } - return 0; + return 0; } diff --git a/libcxx/test/libcxx/containers/unord/unord.multimap/db_iterators_9.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp rename from libcxx/test/libcxx/containers/unord/unord.multimap/db_iterators_9.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp --- a/libcxx/test/libcxx/containers/unord/unord.multimap/db_iterators_9.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp @@ -6,32 +6,37 @@ // //===----------------------------------------------------------------------===// -// +// // Increment iterator past end. -// UNSUPPORTED: libcxx-no-debug-mode -// UNSUPPORTED: c++03 - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 -#include #include -#include +#include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef std::unordered_multimap, std::equal_to, - min_allocator>> C; - C c; - c.insert(std::make_pair(1, "one")); + { + 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, min_allocator > 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 unordered container iterator"); + TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator"); + } - return 0; + return 0; } diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_11.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_11.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.iterators/db_iterators_11.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp @@ -10,23 +10,31 @@ // Index iterator out of bounds. -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef std::basic_string, min_allocator > 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::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, min_allocator > 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; } diff --git a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_10.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp rename from libcxx/test/libcxx/containers/sequences/vector/db_iterators_10.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/vector/db_iterators_10.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp @@ -6,26 +6,32 @@ // //===----------------------------------------------------------------------===// -// +// // Subtract iterators from different containers. -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 -#include +#include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" #include "min_allocator.h" int main(int, char**) { - typedef int T; - typedef std::vector > C; - C c1; - C c2; - TEST_LIBCPP_ASSERT_FAILURE(c1.begin() - c2.begin(), "Attempted to subtract incompatible iterators"); + { + 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, min_allocator > S; + S s1; + S s2; + TEST_LIBCPP_ASSERT_FAILURE(s1.begin() - s2.begin(), "Attempted to subtract incompatible iterators"); + } return 0; } diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db1.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db1.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db1.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp @@ -10,20 +10,27 @@ // Call erase(const_iterator position) with end() -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" +#include "min_allocator.h" + +int main(int, char**) { + { + typedef std::basic_string, min_allocator > 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"); + } -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; + return 0; } diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_pop_back_db1.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_pop_back_db1.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_pop_back_db1.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp @@ -10,17 +10,14 @@ // void pop_back(); -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { std::string s; TEST_LIBCPP_ASSERT_FAILURE(s.pop_back(), "string::pop_back(): string is already empty"); diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// 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 + +#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, min_allocator > 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; +} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp @@ -0,0 +1,91 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// 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 + +#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, min_allocator > 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, min_allocator > 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, min_allocator > 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, min_allocator > 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; +} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp @@ -11,7 +11,6 @@ // 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 @@ -22,11 +21,9 @@ #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { typedef std::string S; S s; S s2; diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_iter_iter_db1.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_iter_iter_db1.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_iter_iter_db1.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp @@ -11,17 +11,14 @@ // template // iterator insert(const_iterator p, InputIterator first, InputIterator last); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { std::string v; std::string v2; char a[] = "123"; diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_size_char_db1.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp rename from libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_size_char_db1.pass.cpp rename to libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_size_char_db1.pass.cpp +++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp @@ -10,17 +10,14 @@ // iterator insert(const_iterator p, size_type n, charT c); -// UNSUPPORTED: libcxx-no-debug-mode - +// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 #include -#include "test_macros.h" -#include "debug_macros.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { std::string s; std::string s2; TEST_LIBCPP_ASSERT_FAILURE( diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db2.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db2.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call erase(const_iterator position) with iterator from another container - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db3.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db3.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db3.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call erase(const_iterator position) with end() - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::basic_string, min_allocator > 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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db4.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db4.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_db4.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// Call erase(const_iterator position) with iterator from another container - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::basic_string, min_allocator > 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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db1.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db1.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db1.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db2.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db2.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db2.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db3.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db3.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db3.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db4.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db4.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db4.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db5.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db5.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db5.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::basic_string, min_allocator > 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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db6.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db6.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db6.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::basic_string, min_allocator > 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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db7.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db7.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db7.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::basic_string, min_allocator > 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; -} diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db8.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db8.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/erase_iter_iter_db8.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// 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 - -#include "test_macros.h" -#include "debug_macros.h" -#include "min_allocator.h" - -int main(int, char**) { - typedef std::basic_string, min_allocator > 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; -} diff --git a/libcxx/test/libcxx/strings/string.view/assert.ctor.pointer.pass.cpp b/libcxx/test/libcxx/strings/string.view/assert.ctor.pointer.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/strings/string.view/assert.ctor.pointer.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache 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 + +#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; +} diff --git a/libcxx/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp b/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception.pass.cpp rename from libcxx/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp rename to libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception.pass.cpp --- a/libcxx/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp +++ b/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception.pass.cpp @@ -6,12 +6,10 @@ // //===----------------------------------------------------------------------===// -// 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 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 // @@ -22,26 +20,21 @@ #include #include -#include -#include -#include "test_macros.h" -#include "debug_mode_helper.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { { typedef int T; std::promise p; - - EXPECT_DEATH( p.set_exception(std::exception_ptr()) ); + TEST_LIBCPP_ASSERT_FAILURE(p.set_exception(std::exception_ptr()), "promise::set_exception: received nullptr"); } + { typedef int& T; std::promise p; - - EXPECT_DEATH( p.set_exception(std::exception_ptr()) ); + TEST_LIBCPP_ASSERT_FAILURE(p.set_exception(std::exception_ptr()), "promise::set_exception: received nullptr"); } - return 0; + return 0; } diff --git a/libcxx/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp b/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception_at_thread_exit.pass.cpp rename from libcxx/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp rename to libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception_at_thread_exit.pass.cpp --- a/libcxx/test/libcxx/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp +++ b/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception_at_thread_exit.pass.cpp @@ -6,12 +6,10 @@ // //===----------------------------------------------------------------------===// -// 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 +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 // @@ -22,27 +20,21 @@ #include #include -#include -#include -#include "test_macros.h" -#include "debug_mode_helper.h" +#include "check_assertion.h" -int main(int, char**) -{ +int main(int, char**) { { typedef int T; std::promise p; - - EXPECT_DEATH( p.set_exception_at_thread_exit(std::exception_ptr()) ); - + 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 p; - - EXPECT_DEATH( p.set_exception_at_thread_exit(std::exception_ptr()) ); + TEST_LIBCPP_ASSERT_FAILURE(p.set_exception_at_thread_exit(std::exception_ptr()), "promise::set_exception_at_thread_exit: received nullptr"); } - return 0; + return 0; } diff --git a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.dereference.pass.cpp b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.dereference.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.dereference.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// constexpr T& optional::operator*() &; +// constexpr T&& optional::operator*() &&; +// constexpr const T& optional::operator*() const &; +// constexpr T&& optional::operator*() const &&; + +// UNSUPPORTED: c++11, c++14 + +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 + +#include + +#include "check_assertion.h" + +int main(int, char**) { + // & + { + std::optional opt; + TEST_LIBCPP_ASSERT_FAILURE(*opt, "optional operator* called on a disengaged value"); + } + + // && + { + std::optional opt; + TEST_LIBCPP_ASSERT_FAILURE(*std::move(opt), "optional operator* called on a disengaged value"); + } + + // const & + { + const std::optional opt; + TEST_LIBCPP_ASSERT_FAILURE(*opt, "optional operator* called on a disengaged value"); + } + + // const && + { + const std::optional opt; + TEST_LIBCPP_ASSERT_FAILURE(*std::move(opt), "optional operator* called on a disengaged value"); + } + + return 0; +} diff --git a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.op_arrow.pass.cpp b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.op_arrow.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/assert.op_arrow.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// constexpr T* optional::operator->(); +// constexpr const T* optional::operator->() const; + +// UNSUPPORTED: c++11, c++14 + +// UNSUPPORTED: c++03, windows, libcxx-no-debug-mode +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0 + +#include + +#include "check_assertion.h" + +struct X { + int test() const { return 3; } +}; + +int main(int, char**) { + { + std::optional opt; + TEST_LIBCPP_ASSERT_FAILURE(opt->test(), "optional operator-> called on a disengaged value"); + } + + { + const std::optional opt; + TEST_LIBCPP_ASSERT_FAILURE(opt->test(), "optional operator-> called on a disengaged value"); + } + + return 0; +} diff --git a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14 -// - -// constexpr T& optional::operator*() &; - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - std::optional opt; - TEST_LIBCPP_ASSERT_FAILURE(*opt, "optional operator* called on a disengaged value"); - - return 0; -} diff --git a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14 -// - -// constexpr const T& optional::operator*() const &; - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - const std::optional opt; - TEST_LIBCPP_ASSERT_FAILURE(*opt, "optional operator* called on a disengaged value"); - - return 0; -} diff --git a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/dereference_const_rvalue.pass.cpp b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/dereference_const_rvalue.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/dereference_const_rvalue.pass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14 -// - -// constexpr T&& optional::operator*() const &&; - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - const std::optional opt; - TEST_LIBCPP_ASSERT_FAILURE(*std::move(opt), "optional operator* called on a disengaged value"); - - return 0; -} diff --git a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/dereference_rvalue.pass.cpp b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/dereference_rvalue.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/dereference_rvalue.pass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14 -// - -// constexpr T&& optional::operator*() &&; - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -int main(int, char**) { - std::optional opt; - TEST_LIBCPP_ASSERT_FAILURE(*std::move(opt), "optional operator* called on a disengaged value"); - - return 0; -} diff --git a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14 -// - -// constexpr T* optional::operator->(); - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -struct X { - int test() noexcept {return 3;} -}; - -int main(int, char**) { - std::optional opt; - TEST_LIBCPP_ASSERT_FAILURE(opt->test(), "optional operator-> called on a disengaged value"); - - return 0; -} diff --git a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp b/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp deleted file mode 100644 --- a/libcxx/test/libcxx/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++03, c++11, c++14 -// - -// constexpr const T* optional::operator->() const; - -// UNSUPPORTED: libcxx-no-debug-mode - -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 - -#include - -#include "test_macros.h" -#include "debug_macros.h" - -struct X { - int test() const {return 3;} -}; - -int main(int, char**) { - const std::optional opt; - TEST_LIBCPP_ASSERT_FAILURE(opt->test(), "optional operator-> called on a disengaged value"); - - return 0; -} diff --git a/libcxx/test/support/debug_mode_helper.h b/libcxx/test/support/check_assertion.h rename from libcxx/test/support/debug_mode_helper.h rename to libcxx/test/support/check_assertion.h --- a/libcxx/test/support/debug_mode_helper.h +++ b/libcxx/test/support/check_assertion.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef TEST_SUPPORT_DEBUG_MODE_HELPER_H -#define TEST_SUPPORT_DEBUG_MODE_HELPER_H +#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 @@ -294,4 +294,6 @@ #define EXPECT_DEATH_MATCHES(Matcher, ...) assert((ExpectDeath(#__VA_ARGS__, [&]() { __VA_ARGS__; }, Matcher))) -#endif // TEST_SUPPORT_DEBUG_MODE_HELPER_H +#define TEST_LIBCPP_ASSERT_FAILURE(expr, message) assert((ExpectDeath(#expr, [&]() { (void)(expr); }, DebugInfoMatcher(message)))) + +#endif // TEST_SUPPORT_CHECK_ASSERTION_H diff --git a/libcxx/test/support/container_debug_tests.h b/libcxx/test/support/container_debug_tests.h --- a/libcxx/test/support/container_debug_tests.h +++ b/libcxx/test/support/container_debug_tests.h @@ -24,9 +24,9 @@ #include #include -#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 diff --git a/libcxx/test/support/debug_macros.h b/libcxx/test/support/debug_macros.h deleted file mode 100644 --- a/libcxx/test/support/debug_macros.h +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef TEST_SUPPORT_DEBUG_MACROS_H -#define TEST_SUPPORT_DEBUG_MACROS_H - -#include <__debug> -#include -#include - -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 diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py --- a/libcxx/utils/libcxx/test/params.py +++ b/libcxx/utils/libcxx/test/params.py @@ -125,6 +125,7 @@ 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 ])),