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