| 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 | // <set> |
| 10 | |
| 11 | // class multiset |
| 12 | |
| 13 | // template <class InputIterator> |
| 14 | // multiset(InputIterator first, InputIterator last, |
| 15 | // const value_compare& comp, const allocator_type& a); |
| 16 | |
| 17 | #include <set> |
| 18 | #include <cassert> |
| 19 | |
| 20 | #include "test_macros.h" |
| 21 | #include "test_iterators.h" |
| 22 | #include "../../../test_compare.h" |
| 23 | #include "test_allocator.h" |
| 24 | |
| 25 | int main(int, char**) { |
| 26 | { |
| 27 | typedef int V; |
| 28 | V ar[] = {1, 1, 1, 2, 2, 2, 3, 3, 3}; |
| 29 | typedef test_less<V> C; |
| 30 | typedef test_allocator<V> A; |
| 31 | std::multiset<V, C, A> m( |
| 32 | cpp17_input_iterator<const V*>(ar), |
| 33 | cpp17_input_iterator<const V*>(ar + sizeof(ar) / sizeof(ar[0])), |
| 34 | C(5), |
| 35 | A(7)); |
| 36 | assert(m.value_comp() == C(5)); |
| 37 | assert(m.get_allocator() == A(7)); |
| 38 | assert(m.size() == 9); |
| 39 | assert(std::distance(m.begin(), m.end()) == 9); |
| 40 | assert(*std::next(m.begin(), 0) == 1); |
| 41 | assert(*std::next(m.begin(), 1) == 1); |
| 42 | assert(*std::next(m.begin(), 2) == 1); |
| 43 | assert(*std::next(m.begin(), 3) == 2); |
| 44 | assert(*std::next(m.begin(), 4) == 2); |
| 45 | assert(*std::next(m.begin(), 5) == 2); |
| 46 | assert(*std::next(m.begin(), 6) == 3); |
| 47 | assert(*std::next(m.begin(), 7) == 3); |
| 48 | assert(*std::next(m.begin(), 8) == 3); |
| 49 | } |
| 50 | #if TEST_STD_VER > 11 |
| 51 | { |
| 52 | typedef int V; |
| 53 | V ar[] = {1, 1, 1, 2, 2, 2, 3, 3, 3}; |
| 54 | typedef test_allocator<V> A; |
| 55 | typedef test_less<int> C; |
| 56 | A a; |
| 57 | std::multiset<V, C, A> m(ar, ar + sizeof(ar) / sizeof(ar[0]), a); |
| 58 | |
| 59 | assert(m.size() == 9); |
| 60 | assert(std::distance(m.begin(), m.end()) == 9); |
| 61 | assert(*std::next(m.begin(), 0) == 1); |
| 62 | assert(*std::next(m.begin(), 1) == 1); |
| 63 | assert(*std::next(m.begin(), 2) == 1); |
| 64 | assert(*std::next(m.begin(), 3) == 2); |
| 65 | assert(*std::next(m.begin(), 4) == 2); |
| 66 | assert(*std::next(m.begin(), 5) == 2); |
| 67 | assert(*std::next(m.begin(), 6) == 3); |
| 68 | assert(*std::next(m.begin(), 7) == 3); |
| 69 | assert(*std::next(m.begin(), 8) == 3); |
| 70 | assert(m.get_allocator() == a); |
| 71 | } |
| 72 | #endif |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |