xref: /aosp_15_r20/external/libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <set>
11 
12 // class multiset
13 
14 // iterator insert(const value_type& v);
15 
16 #include <set>
17 #include <cassert>
18 
19 #include "min_allocator.h"
20 
21 template<class Container>
do_insert_cv_test()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 == prev(m.end()));
43     assert(m.size() == 3);
44     assert(*r == 3);
45 
46     r = m.insert(v3);
47     assert(r == prev(m.end()));
48     assert(m.size() == 4);
49     assert(*r == 3);
50 }
51 
main()52 int main()
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