| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_map> | ||
|
|
||
| // Increment local_iterator past end. | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_map> | ||
| #include <cassert> | ||
| #include <string> | ||
|
|
||
| #include "check_assertion.h" | ||
| #include "min_allocator.h" | ||
|
|
||
| int main(int, char**) { | ||
| { | ||
| typedef std::unordered_multimap<int, std::string> C; | ||
| C c; | ||
| c.insert(std::make_pair(42, std::string())); | ||
| C::size_type b = c.bucket(42); | ||
| C::local_iterator i = c.begin(b); | ||
| assert(i != c.end(b)); | ||
| ++i; | ||
| assert(i == c.end(b)); | ||
| TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container local_iterator"); | ||
| } | ||
|
|
||
| { | ||
| typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, | ||
| min_allocator<std::pair<const int, std::string>>> C; | ||
| C c({{1, std::string()}}); | ||
| c.insert(std::make_pair(42, std::string())); | ||
| C::size_type b = c.bucket(42); | ||
| C::local_iterator i = c.begin(b); | ||
| assert(i != c.end(b)); | ||
| ++i; | ||
| assert(i == c.end(b)); | ||
| TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container local_iterator"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_map> | ||
|
|
||
| // Call erase(const_iterator position) with invalid iterators | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_map> | ||
|
|
||
| #include "check_assertion.h" | ||
|
|
||
| int main(int, char**) { | ||
| // With end() | ||
| { | ||
| typedef std::pair<int, int> P; | ||
| P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; | ||
| std::unordered_multimap<int, int> l1(a1, a1+3); | ||
| std::unordered_multimap<int, int>::const_iterator i = l1.end(); | ||
| TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), | ||
| "unordered container erase(iterator) called with a non-dereferenceable iterator"); | ||
| } | ||
|
|
||
| // With iterator from another container | ||
| { | ||
| typedef std::pair<int, int> P; | ||
| P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; | ||
| std::unordered_multimap<int, int> l1(a1, a1+3); | ||
| std::unordered_multimap<int, int> l2(a1, a1+3); | ||
| std::unordered_multimap<int, int>::const_iterator i = l2.begin(); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| l1.erase(i), "unordered container erase(iterator) called with an iterator not referring to this container"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_map> | ||
|
|
||
| // Call erase(const_iterator first, const_iterator last); with invalid iterators | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_map> | ||
|
|
||
| #include "check_assertion.h" | ||
|
|
||
| int main(int, char**) { | ||
| // With first iterator from another container | ||
| { | ||
| typedef std::pair<int, int> P; | ||
| P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; | ||
| std::unordered_multimap<int, int> l1(a1, a1+3); | ||
| std::unordered_multimap<int, int> l2(a1, a1+3); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| l1.erase(l2.cbegin(), std::next(l1.cbegin())), | ||
| "unordered container::erase(iterator, iterator) called with an iterator not referring to this container"); | ||
| } | ||
|
|
||
| // With second iterator from another container | ||
| { | ||
| typedef std::pair<int, int> P; | ||
| P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; | ||
| std::unordered_multimap<int, int> l1(a1, a1+3); | ||
| std::unordered_multimap<int, int> l2(a1, a1+3); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| l1.erase(l1.cbegin(), std::next(l2.cbegin())), | ||
| "unordered container::erase(iterator, iterator) called with an iterator not referring to this container"); | ||
| } | ||
|
|
||
| // With both iterators from another container | ||
| { | ||
| typedef std::pair<int, int> P; | ||
| P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; | ||
| std::unordered_multimap<int, int> l1(a1, a1+3); | ||
| std::unordered_multimap<int, int> l2(a1, a1+3); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| l1.erase(l2.cbegin(), std::next(l2.cbegin())), | ||
| "unordered container::erase(iterator, iterator) called with an iterator not referring to this container"); | ||
| } | ||
|
|
||
| // With an invalid range | ||
| { | ||
| typedef std::pair<int, int> P; | ||
| P a1[] = {P(1, 1), P(2, 2), P(3, 3)}; | ||
| std::unordered_multimap<int, int> l1(a1, a1+3); | ||
| TEST_LIBCPP_ASSERT_FAILURE(l1.erase(std::next(l1.cbegin()), l1.cbegin()), | ||
| "Attempted to increment a non-incrementable unordered container const_iterator"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_set> | ||
|
|
||
| // Call erase(const_iterator position) with invalid iterators | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_set> | ||
|
|
||
| #include "check_assertion.h" | ||
|
|
||
| int main(int, char**) { | ||
| // With end() | ||
| { | ||
| int a1[] = {1, 2, 3}; | ||
| std::unordered_multiset<int> l1(a1, a1+3); | ||
| std::unordered_multiset<int>::const_iterator i = l1.end(); | ||
| TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), | ||
| "unordered container erase(iterator) called with a non-dereferenceable iterator"); | ||
| } | ||
|
|
||
| // With iterator from another container | ||
| { | ||
| int a1[] = {1, 2, 3}; | ||
| std::unordered_multiset<int> l1(a1, a1+3); | ||
| std::unordered_multiset<int> l2(a1, a1+3); | ||
| std::unordered_multiset<int>::const_iterator i = l2.begin(); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| l1.erase(i), "unordered container erase(iterator) called with an iterator not referring to this container"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_set> | ||
|
|
||
| // Call erase(const_iterator first, const_iterator last); with invalid iterators | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_set> | ||
|
|
||
| #include "check_assertion.h" | ||
|
|
||
| int main(int, char**) { | ||
| // With first iterator from another container | ||
| { | ||
| int a1[] = {1, 2, 3}; | ||
| std::unordered_multiset<int> l1(a1, a1+3); | ||
| std::unordered_multiset<int> l2(a1, a1+3); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| l1.erase(l2.cbegin(), std::next(l1.cbegin())), | ||
| "unordered container::erase(iterator, iterator) called with an iterator not referring to this container"); | ||
| } | ||
|
|
||
| // With second iterator from another container | ||
| { | ||
| int a1[] = {1, 2, 3}; | ||
| std::unordered_multiset<int> l1(a1, a1+3); | ||
| std::unordered_multiset<int> l2(a1, a1+3); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| l1.erase(l1.cbegin(), std::next(l2.cbegin())), | ||
| "unordered container::erase(iterator, iterator) called with an iterator not referring to this container"); | ||
| } | ||
|
|
||
| // With both iterators from another container | ||
| { | ||
| int a1[] = {1, 2, 3}; | ||
| std::unordered_multiset<int> l1(a1, a1+3); | ||
| std::unordered_multiset<int> l2(a1, a1+3); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| l1.erase(l2.cbegin(), std::next(l2.cbegin())), | ||
| "unordered container::erase(iterator, iterator) called with an iterator not referring to this container"); | ||
| } | ||
|
|
||
| // With an invalid range | ||
| { | ||
| int a1[] = {1, 2, 3}; | ||
| std::unordered_multiset<int> l1(a1, a1+3); | ||
| TEST_LIBCPP_ASSERT_FAILURE(l1.erase(std::next(l1.cbegin()), l1.cbegin()), | ||
| "Attempted to increment a non-incrementable unordered container const_iterator"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_set> | ||
|
|
||
| // Dereference non-dereferenceable iterator. | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_set> | ||
|
|
||
| #include "check_assertion.h" | ||
| #include "min_allocator.h" | ||
|
|
||
| int main(int, char**) { | ||
| { | ||
| typedef int T; | ||
| typedef std::unordered_multiset<T> C; | ||
| C c(1); | ||
| C::iterator i = c.end(); | ||
| TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container const_iterator"); | ||
| } | ||
|
|
||
| { | ||
| typedef int T; | ||
| typedef std::unordered_multiset<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C; | ||
| C c(1); | ||
| C::iterator i = c.end(); | ||
| TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container const_iterator"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_set> | ||
|
|
||
| // Increment iterator past end. | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_set> | ||
| #include <cassert> | ||
|
|
||
| #include "check_assertion.h" | ||
| #include "min_allocator.h" | ||
|
|
||
| int main(int, char**) { | ||
| { | ||
| typedef int T; | ||
| typedef std::unordered_multiset<T> C; | ||
| C c; | ||
| c.insert(42); | ||
| C::iterator i = c.begin(); | ||
| assert(i != c.end()); | ||
| ++i; | ||
| assert(i == c.end()); | ||
| TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container const_iterator"); | ||
| } | ||
|
|
||
| { | ||
| typedef int T; | ||
| typedef std::unordered_multiset<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C; | ||
| C c({42}); | ||
| C::iterator i = c.begin(); | ||
| assert(i != c.end()); | ||
| ++i; | ||
| assert(i == c.end()); | ||
| TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container const_iterator"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_set> | ||
|
|
||
| // Dereference non-dereferenceable iterator. | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_set> | ||
|
|
||
| #include "check_assertion.h" | ||
| #include "min_allocator.h" | ||
|
|
||
| int main(int, char**) { | ||
| { | ||
| typedef int T; | ||
| typedef std::unordered_multiset<T> C; | ||
| C c(1); | ||
| C::local_iterator i = c.end(0); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| *i, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); | ||
| } | ||
|
|
||
| { | ||
| typedef int T; | ||
| typedef std::unordered_multiset<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C; | ||
| C c(1); | ||
| C::local_iterator i = c.end(0); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| *i, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_set> | ||
|
|
||
| // Increment local_iterator past end. | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_set> | ||
| #include <cassert> | ||
|
|
||
| #include "check_assertion.h" | ||
| #include "min_allocator.h" | ||
|
|
||
| int main(int, char**) { | ||
| { | ||
| typedef int T; | ||
| typedef std::unordered_multiset<T> C; | ||
| C c; | ||
| c.insert(42); | ||
| C::size_type b = c.bucket(42); | ||
| C::local_iterator i = c.begin(b); | ||
| assert(i != c.end(b)); | ||
| ++i; | ||
| assert(i == c.end(b)); | ||
| TEST_LIBCPP_ASSERT_FAILURE(++i, | ||
| "Attempted to increment a non-incrementable unordered container const_local_iterator"); | ||
| } | ||
|
|
||
| { | ||
| typedef int T; | ||
| typedef std::unordered_multiset<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C; | ||
| C c({42}); | ||
| C::size_type b = c.bucket(42); | ||
| C::local_iterator i = c.begin(b); | ||
| assert(i != c.end(b)); | ||
| ++i; | ||
| assert(i == c.end(b)); | ||
| TEST_LIBCPP_ASSERT_FAILURE(++i, | ||
| "Attempted to increment a non-incrementable unordered container const_local_iterator"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_set> | ||
|
|
||
| // Call erase(const_iterator position) with invalid iterators | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_set> | ||
|
|
||
| #include "check_assertion.h" | ||
|
|
||
| int main(int, char**) { | ||
| // With end() | ||
| { | ||
| int a1[] = {1, 2, 3}; | ||
| std::unordered_set<int> l1(a1, a1+3); | ||
| std::unordered_set<int>::const_iterator i = l1.end(); | ||
| TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), | ||
| "unordered container erase(iterator) called with a non-dereferenceable iterator"); | ||
| } | ||
|
|
||
| // With iterator from another container | ||
| { | ||
| int a1[] = {1, 2, 3}; | ||
| std::unordered_set<int> l1(a1, a1+3); | ||
| std::unordered_set<int> l2(a1, a1+3); | ||
| std::unordered_set<int>::const_iterator i = l2.begin(); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| l1.erase(i), "unordered container erase(iterator) called with an iterator not referring to this container"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_set> | ||
|
|
||
| // Call erase(const_iterator first, const_iterator last); with first iterator from another container | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_set> | ||
|
|
||
| #include "check_assertion.h" | ||
|
|
||
| int main(int, char**) { | ||
| // With first iterator from another container | ||
| { | ||
| int a1[] = {1, 2, 3}; | ||
| std::unordered_set<int> l1(a1, a1+3); | ||
| std::unordered_set<int> l2(a1, a1+3); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| l1.erase(l2.cbegin(), std::next(l1.cbegin())), | ||
| "unordered container::erase(iterator, iterator) called with an iterator not referring to this container"); | ||
| } | ||
|
|
||
| // With second iterator from another container | ||
| { | ||
| int a1[] = {1, 2, 3}; | ||
| std::unordered_set<int> l1(a1, a1+3); | ||
| std::unordered_set<int> l2(a1, a1+3); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| l1.erase(l1.cbegin(), std::next(l2.cbegin())), | ||
| "unordered container::erase(iterator, iterator) called with an iterator not referring to this container"); | ||
| } | ||
|
|
||
| // With both iterators from another container | ||
| { | ||
| int a1[] = {1, 2, 3}; | ||
| std::unordered_set<int> l1(a1, a1+3); | ||
| std::unordered_set<int> l2(a1, a1+3); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| l1.erase(l2.cbegin(), std::next(l2.cbegin())), | ||
| "unordered container::erase(iterator, iterator) called with an iterator not referring to this container"); | ||
| } | ||
|
|
||
| // With an invalid range | ||
| { | ||
| int a1[] = {1, 2, 3}; | ||
| std::unordered_set<int> l1(a1, a1+3); | ||
| TEST_LIBCPP_ASSERT_FAILURE(l1.erase(std::next(l1.cbegin()), l1.cbegin()), | ||
| "Attempted to increment a non-incrementable unordered container const_iterator"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_set> | ||
|
|
||
| // Dereference non-dereferenceable iterator. | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_set> | ||
|
|
||
| #include "check_assertion.h" | ||
| #include "min_allocator.h" | ||
|
|
||
| int main(int, char**) { | ||
| { | ||
| typedef int T; | ||
| typedef std::unordered_set<T> C; | ||
| C c(1); | ||
| C::iterator i = c.end(); | ||
| TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container const_iterator"); | ||
| } | ||
|
|
||
| { | ||
| typedef int T; | ||
| typedef std::unordered_set<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C; | ||
| C c(1); | ||
| C::iterator i = c.end(); | ||
| TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable unordered container const_iterator"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_set> | ||
|
|
||
| // Increment iterator past end. | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_set> | ||
| #include <cassert> | ||
|
|
||
| #include "check_assertion.h" | ||
| #include "min_allocator.h" | ||
|
|
||
| int main(int, char**) { | ||
| { | ||
| typedef int T; | ||
| typedef std::unordered_set<T> C; | ||
| C c; | ||
| c.insert(42); | ||
| C::iterator i = c.begin(); | ||
| assert(i != c.end()); | ||
| ++i; | ||
| assert(i == c.end()); | ||
| TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container const_iterator"); | ||
| } | ||
|
|
||
| { | ||
| typedef int T; | ||
| typedef std::unordered_set<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C; | ||
| C c({42}); | ||
| C::iterator i = c.begin(); | ||
| assert(i != c.end()); | ||
| ++i; | ||
| assert(i == c.end()); | ||
| TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container const_iterator"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_set> | ||
|
|
||
| // Dereference non-dereferenceable iterator. | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_set> | ||
|
|
||
| #include "check_assertion.h" | ||
| #include "min_allocator.h" | ||
|
|
||
| int main(int, char**) { | ||
| { | ||
| typedef int T; | ||
| typedef std::unordered_set<T> C; | ||
| C c(1); | ||
| C::local_iterator i = c.end(0); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| *i, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); | ||
| } | ||
|
|
||
| { | ||
| typedef int T; | ||
| typedef std::unordered_set<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C; | ||
| C c(1); | ||
| C::local_iterator i = c.end(0); | ||
| TEST_LIBCPP_ASSERT_FAILURE( | ||
| *i, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // <unordered_set> | ||
|
|
||
| // Increment local_iterator past end. | ||
|
|
||
| // UNSUPPORTED: libcxx-no-debug-mode, c++03, windows | ||
| // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1 | ||
|
|
||
| #include <unordered_set> | ||
| #include <cassert> | ||
|
|
||
| #include "check_assertion.h" | ||
| #include "min_allocator.h" | ||
|
|
||
| int main(int, char**) { | ||
| { | ||
| typedef int T; | ||
| typedef std::unordered_set<T> C; | ||
| C c; | ||
| c.insert(42); | ||
| C::size_type b = c.bucket(42); | ||
| C::local_iterator i = c.begin(b); | ||
| assert(i != c.end(b)); | ||
| ++i; | ||
| assert(i == c.end(b)); | ||
| TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container const_local_iterator"); | ||
| } | ||
|
|
||
| { | ||
| typedef int T; | ||
| typedef std::unordered_set<T, std::hash<T>, std::equal_to<T>, min_allocator<T>> C; | ||
| C c({42}); | ||
| C::size_type b = c.bucket(42); | ||
| C::local_iterator i = c.begin(b); | ||
| assert(i != c.end(b)); | ||
| ++i; | ||
| assert(i == c.end(b)); | ||
| TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable unordered container const_local_iterator"); | ||
| } | ||
|
|
||
| return 0; | ||
| } |