llvm-project
70 строк · 1.6 Кб
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// <map>
10
11// class multimap
12
13// iterator insert(const value_type& v);
14
15#include <map>
16#include <cassert>
17
18#include "test_macros.h"
19#include "min_allocator.h"
20
21template <class Container>
22void do_insert_test() {
23typedef Container M;
24typedef typename M::iterator R;
25typedef typename M::value_type VT;
26M m;
27const VT v1(2, 2.5);
28R r = m.insert(v1);
29assert(r == m.begin());
30assert(m.size() == 1);
31assert(r->first == 2);
32assert(r->second == 2.5);
33
34const VT v2(1, 1.5);
35r = m.insert(v2);
36assert(r == m.begin());
37assert(m.size() == 2);
38assert(r->first == 1);
39assert(r->second == 1.5);
40
41const VT v3(3, 3.5);
42r = m.insert(v3);
43assert(r == std::prev(m.end()));
44assert(m.size() == 3);
45assert(r->first == 3);
46assert(r->second == 3.5);
47
48const VT v4(3, 3.5);
49r = m.insert(v4);
50assert(r == std::prev(m.end()));
51assert(m.size() == 4);
52assert(r->first == 3);
53assert(r->second == 3.5);
54}
55
56int main(int, char**)
57{
58{
59typedef std::multimap<int, double> Container;
60do_insert_test<Container>();
61}
62#if TEST_STD_VER >= 11
63{
64typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> Container;
65do_insert_test<Container>();
66}
67#endif
68
69return 0;
70}
71