| 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 | // iterator insert(const value_type& v); |
| 14 | |
| 15 | #include <set> |
| 16 | #include <cassert> |
| 17 | |
| 18 | #include "test_macros.h" |
| 19 | #include "min_allocator.h" |
| 20 | |
| 21 | template <class Container> |
| 22 | void do_insert_cv_test() { |
| 23 | typedef Container M; |
| 24 | typedef typename M::iterator R; |
| 25 | typedef typename M::value_type VT; |
| 26 | M m; |
| 27 | const VT v1(2); |
| 28 | R r = m.insert(v1); |
| 29 | assert(r == m.begin()); |
| 30 | assert(m.size() == 1); |
| 31 | assert(*r == 2); |
| 32 | |
| 33 | const VT v2(1); |
| 34 | r = m.insert(v2); |
| 35 | assert(r == m.begin()); |
| 36 | assert(m.size() == 2); |
| 37 | assert(*r == 1); |
| 38 | |
| 39 | const VT v3(3); |
| 40 | r = m.insert(v3); |
| 41 | assert(r == std::prev(m.end())); |
| 42 | assert(m.size() == 3); |
| 43 | assert(*r == 3); |
| 44 | |
| 45 | r = m.insert(v3); |
| 46 | assert(r == std::prev(m.end())); |
| 47 | assert(m.size() == 4); |
| 48 | assert(*r == 3); |
| 49 | } |
| 50 | |
| 51 | int main(int, char**) { |
| 52 | do_insert_cv_test<std::multiset<int> >(); |
| 53 | #if TEST_STD_VER >= 11 |
| 54 | { |
| 55 | typedef std::multiset<int, std::less<int>, min_allocator<int>> M; |
| 56 | do_insert_cv_test<M>(); |
| 57 | } |
| 58 | #endif |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |