| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <unordered_map> |
| 10 | |
| 11 | // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, |
| 12 | // class Alloc = allocator<pair<const Key, T>>> |
| 13 | // class unordered_multimap |
| 14 | |
| 15 | // void clear() noexcept; |
| 16 | |
| 17 | #include <unordered_map> |
| 18 | #include <string> |
| 19 | #include <cassert> |
| 20 | |
| 21 | #include "test_macros.h" |
| 22 | #include "min_allocator.h" |
| 23 | |
| 24 | int main(int, char**) { |
| 25 | { |
| 26 | typedef std::unordered_multimap<int, std::string> C; |
| 27 | typedef std::pair<int, std::string> P; |
| 28 | P a[] = { |
| 29 | P(1, "one" ), |
| 30 | P(2, "two" ), |
| 31 | P(3, "three" ), |
| 32 | P(4, "four" ), |
| 33 | P(1, "four" ), |
| 34 | P(2, "four" ), |
| 35 | }; |
| 36 | C c(a, a + sizeof(a) / sizeof(a[0])); |
| 37 | ASSERT_NOEXCEPT(c.clear()); |
| 38 | c.clear(); |
| 39 | assert(c.size() == 0); |
| 40 | } |
| 41 | #if TEST_STD_VER >= 11 |
| 42 | { |
| 43 | typedef std::unordered_multimap<int, |
| 44 | std::string, |
| 45 | std::hash<int>, |
| 46 | std::equal_to<int>, |
| 47 | min_allocator<std::pair<const int, std::string>>> |
| 48 | C; |
| 49 | typedef std::pair<int, std::string> P; |
| 50 | P a[] = { |
| 51 | P(1, "one" ), |
| 52 | P(2, "two" ), |
| 53 | P(3, "three" ), |
| 54 | P(4, "four" ), |
| 55 | P(1, "four" ), |
| 56 | P(2, "four" ), |
| 57 | }; |
| 58 | C c(a, a + sizeof(a) / sizeof(a[0])); |
| 59 | ASSERT_NOEXCEPT(c.clear()); |
| 60 | c.clear(); |
| 61 | assert(c.size() == 0); |
| 62 | } |
| 63 | #endif |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |