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// <map>
12
13// class multimap
14
15// multimap& operator=(initializer_list<value_type> il);
16
17#include <map>
18#include <cassert>
19
20#include "test_macros.h"
21#include "min_allocator.h"
22
23int main(int, char**) {
24 {
25 typedef std::multimap<int, double> C;
26 typedef C::value_type V;
27 C m = {{20, 1}};
28 m = {{1, 1}, {1, 1.5}, {1, 2}, {2, 1}, {2, 1.5}, {2, 2}, {3, 1}, {3, 1.5}, {3, 2}};
29 assert(m.size() == 9);
30 assert(std::distance(m.begin(), m.end()) == 9);
31 C::const_iterator i = m.cbegin();
32 assert(*i == V(1, 1));
33 assert(*++i == V(1, 1.5));
34 assert(*++i == V(1, 2));
35 assert(*++i == V(2, 1));
36 assert(*++i == V(2, 1.5));
37 assert(*++i == V(2, 2));
38 assert(*++i == V(3, 1));
39 assert(*++i == V(3, 1.5));
40 assert(*++i == V(3, 2));
41 }
42 {
43 typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
44 typedef C::value_type V;
45 C m = {{20, 1}};
46 m = {{1, 1}, {1, 1.5}, {1, 2}, {2, 1}, {2, 1.5}, {2, 2}, {3, 1}, {3, 1.5}, {3, 2}};
47 assert(m.size() == 9);
48 assert(std::distance(m.begin(), m.end()) == 9);
49 C::const_iterator i = m.cbegin();
50 assert(*i == V(1, 1));
51 assert(*++i == V(1, 1.5));
52 assert(*++i == V(1, 2));
53 assert(*++i == V(2, 1));
54 assert(*++i == V(2, 1.5));
55 assert(*++i == V(2, 2));
56 assert(*++i == V(3, 1));
57 assert(*++i == V(3, 1.5));
58 assert(*++i == V(3, 2));
59 }
60
61 return 0;
62}
63

source code of libcxx/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp