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 | // <unordered_map> |
10 | |
11 | // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, |
12 | // class Alloc = allocator<pair<const Key, T>>> |
13 | // class unordered_multimap |
14 | |
15 | // iterator insert(const value_type& x); |
16 | |
17 | #include <unordered_map> |
18 | #include <cassert> |
19 | |
20 | #include "test_macros.h" |
21 | #include "min_allocator.h" |
22 | |
23 | template<class Container> |
24 | void do_insert_const_lvalue_test() |
25 | { |
26 | typedef Container C; |
27 | typedef typename C::iterator R; |
28 | typedef typename C::value_type VT; |
29 | C c; |
30 | const VT v1(3.5, 3); |
31 | R r = c.insert(v1); |
32 | assert(c.size() == 1); |
33 | assert(r->first == 3.5); |
34 | assert(r->second == 3); |
35 | |
36 | const VT v2(3.5, 4); |
37 | r = c.insert(v2); |
38 | assert(c.size() == 2); |
39 | assert(r->first == 3.5); |
40 | assert(r->second == 4); |
41 | |
42 | const VT v3(4.5, 4); |
43 | r = c.insert(v3); |
44 | assert(c.size() == 3); |
45 | assert(r->first == 4.5); |
46 | assert(r->second == 4); |
47 | |
48 | const VT v4(5.5, 4); |
49 | r = c.insert(v4); |
50 | assert(c.size() == 4); |
51 | assert(r->first == 5.5); |
52 | assert(r->second == 4); |
53 | } |
54 | |
55 | int main(int, char**) |
56 | { |
57 | do_insert_const_lvalue_test<std::unordered_multimap<double, int> >(); |
58 | #if TEST_STD_VER >= 11 |
59 | { |
60 | typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>, |
61 | min_allocator<std::pair<const double, int>>> C; |
62 | do_insert_const_lvalue_test<C>(); |
63 | } |
64 | #endif |
65 | |
66 | return 0; |
67 | } |
68 | |