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#include "test_macros.h"
20#include "../../../test_compare.h"
21#include "min_allocator.h"
22
23int main(int, char**) {
24 {
25 typedef test_less<int> Cmp;
26 typedef std::multimap<int, double, Cmp> C;
27 typedef C::value_type V;
28 C m({{1, 1}, {1, 1.5}, {1, 2}, {2, 1}, {2, 1.5}, {2, 2}, {3, 1}, {3, 1.5}, {3, 2}}, Cmp(4));
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 assert(m.key_comp() == Cmp(4));
42 }
43 {
44 typedef test_less<int> Cmp;
45 typedef std::multimap<int, double, Cmp, min_allocator<std::pair<const int, double>>> C;
46 typedef C::value_type V;
47 C m({{1, 1}, {1, 1.5}, {1, 2}, {2, 1}, {2, 1.5}, {2, 2}, {3, 1}, {3, 1.5}, {3, 2}}, Cmp(4));
48 assert(m.size() == 9);
49 assert(std::distance(m.begin(), m.end()) == 9);
50 C::const_iterator i = m.cbegin();
51 assert(*i == V(1, 1));
52 assert(*++i == V(1, 1.5));
53 assert(*++i == V(1, 2));
54 assert(*++i == V(2, 1));
55 assert(*++i == V(2, 1.5));
56 assert(*++i == V(2, 2));
57 assert(*++i == V(3, 1));
58 assert(*++i == V(3, 1.5));
59 assert(*++i == V(3, 2));
60 assert(m.key_comp() == Cmp(4));
61 }
62
63 return 0;
64}
65

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