Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / containers / associative / map / map.modifiers / insert_iter_cv.pass.cpp
blob6260fd9d93e9b89ca754295cd549808a7cd95078
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 //===----------------------------------------------------------------------===//
9 // <map>
11 // class map
13 // iterator insert(const_iterator position, const value_type& v);
15 #include <map>
16 #include <cassert>
18 #include "test_macros.h"
19 #include "min_allocator.h"
21 template <class Container>
22 void do_insert_iter_cv_test()
24 typedef Container M;
25 typedef typename M::iterator R;
26 typedef typename M::value_type VT;
28 M m;
29 const VT v1(2, 2.5);
30 R r = m.insert(m.end(), v1);
31 assert(r == m.begin());
32 assert(m.size() == 1);
33 assert(r->first == 2);
34 assert(r->second == 2.5);
36 const VT v2(1, 1.5);
37 r = m.insert(m.end(), v2);
38 assert(r == m.begin());
39 assert(m.size() == 2);
40 assert(r->first == 1);
41 assert(r->second == 1.5);
43 const VT v3(3, 3.5);
44 r = m.insert(m.end(), v3);
45 assert(r == std::prev(m.end()));
46 assert(m.size() == 3);
47 assert(r->first == 3);
48 assert(r->second == 3.5);
50 const VT v4(3, 4.5);
51 r = m.insert(m.end(), v4);
52 assert(r == std::prev(m.end()));
53 assert(m.size() == 3);
54 assert(r->first == 3);
55 assert(r->second == 3.5);
58 int main(int, char**)
60 do_insert_iter_cv_test<std::map<int, double> >();
61 #if TEST_STD_VER >= 11
63 typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
64 do_insert_iter_cv_test<M>();
66 #endif
68 return 0;