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// UNSUPPORTED: c++03
10
11// <unordered_map>
12
13// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
14// class Alloc = allocator<pair<const Key, T>>>
15// class unordered_map
16
17// void insert(initializer_list<value_type> il);
18
19#include <unordered_map>
20#include <string>
21#include <cassert>
22
23#include "test_macros.h"
24#include "test_iterators.h"
25#include "min_allocator.h"
26
27int main(int, char**)
28{
29 {
30 typedef std::unordered_map<int, std::string> C;
31 typedef std::pair<int, std::string> P;
32 C c;
33 c.insert(
34 l: {
35 P(1, "one"),
36 P(2, "two"),
37 P(3, "three"),
38 P(4, "four"),
39 P(1, "four"),
40 P(2, "four"),
41 }
42 );
43 assert(c.size() == 4);
44 assert(c.at(1) == "one");
45 assert(c.at(2) == "two");
46 assert(c.at(3) == "three");
47 assert(c.at(4) == "four");
48 }
49 {
50 typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
51 min_allocator<std::pair<const int, std::string>>> C;
52 typedef std::pair<int, std::string> P;
53 C c;
54 c.insert(
55 {
56 P(1, "one"),
57 P(2, "two"),
58 P(3, "three"),
59 P(4, "four"),
60 P(1, "four"),
61 P(2, "four"),
62 }
63 );
64 assert(c.size() == 4);
65 assert(c.at(1) == "one");
66 assert(c.at(2) == "two");
67 assert(c.at(3) == "three");
68 assert(c.at(4) == "four");
69 }
70
71 return 0;
72}
73

source code of libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp