llvm-project
104 строки · 2.7 Кб
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// <map>
10
11// class multimap
12
13// multimap(const multimap& m);
14
15#include <map>
16#include <cassert>
17
18#include "test_macros.h"
19#include "../../../test_compare.h"
20#include "test_allocator.h"
21#include "min_allocator.h"
22
23int main(int, char**)
24{
25{
26typedef std::pair<const int, double> V;
27V ar[] =
28{
29V(1, 1),
30V(1, 1.5),
31V(1, 2),
32V(2, 1),
33V(2, 1.5),
34V(2, 2),
35V(3, 1),
36V(3, 1.5),
37V(3, 2),
38};
39typedef test_less<int> C;
40typedef test_allocator<V> A;
41std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
42std::multimap<int, double, C, A> m = mo;
43assert(m == mo);
44assert(m.get_allocator() == A(7));
45assert(m.key_comp() == C(5));
46
47assert(mo.get_allocator() == A(7));
48assert(mo.key_comp() == C(5));
49}
50#if TEST_STD_VER >= 11
51{
52typedef std::pair<const int, double> V;
53V ar[] =
54{
55V(1, 1),
56V(1, 1.5),
57V(1, 2),
58V(2, 1),
59V(2, 1.5),
60V(2, 2),
61V(3, 1),
62V(3, 1.5),
63V(3, 2),
64};
65typedef test_less<int> C;
66typedef other_allocator<V> A;
67std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
68std::multimap<int, double, C, A> m = mo;
69assert(m == mo);
70assert(m.get_allocator() == A(-2));
71assert(m.key_comp() == C(5));
72
73assert(mo.get_allocator() == A(7));
74assert(mo.key_comp() == C(5));
75}
76{
77typedef std::pair<const int, double> V;
78V ar[] =
79{
80V(1, 1),
81V(1, 1.5),
82V(1, 2),
83V(2, 1),
84V(2, 1.5),
85V(2, 2),
86V(3, 1),
87V(3, 1.5),
88V(3, 2),
89};
90typedef test_less<int> C;
91typedef min_allocator<V> A;
92std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
93std::multimap<int, double, C, A> m = mo;
94assert(m == mo);
95assert(m.get_allocator() == A());
96assert(m.key_comp() == C(5));
97
98assert(mo.get_allocator() == A());
99assert(mo.key_comp() == C(5));
100}
101#endif
102
103return 0;
104}
105