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(initializer_list<value_type> il, const key_compare& comp = key_compare());
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 = {{1, 1}, {1, 1.5}, {1, 2}, {2, 1}, {2, 1.5}, {2, 2}, {3, 1}, {3, 1.5}, {3, 2}};
28 assert(m.size() == 9);
29 assert(std::distance(m.begin(), m.end()) == 9);
30 C::const_iterator i = m.cbegin();
31 assert(*i == V(1, 1));
32 assert(*++i == V(1, 1.5));
33 assert(*++i == V(1, 2));
34 assert(*++i == V(2, 1));
35 assert(*++i == V(2, 1.5));
36 assert(*++i == V(2, 2));
37 assert(*++i == V(3, 1));
38 assert(*++i == V(3, 1.5));
39 assert(*++i == V(3, 2));
40 }
41 {
42 typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
43 typedef C::value_type V;
44 C m = {{1, 1}, {1, 1.5}, {1, 2}, {2, 1}, {2, 1.5}, {2, 2}, {3, 1}, {3, 1.5}, {3, 2}};
45 assert(m.size() == 9);
46 assert(std::distance(m.begin(), m.end()) == 9);
47 C::const_iterator i = m.cbegin();
48 assert(*i == V(1, 1));
49 assert(*++i == V(1, 1.5));
50 assert(*++i == V(1, 2));
51 assert(*++i == V(2, 1));
52 assert(*++i == V(2, 1.5));
53 assert(*++i == V(2, 2));
54 assert(*++i == V(3, 1));
55 assert(*++i == V(3, 1.5));
56 assert(*++i == V(3, 2));
57 }
58
59 return 0;
60}
61

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