1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
13 // multiset(const multiset& m);
19 #include "test_macros.h"
20 #include "../../../test_compare.h"
21 #include "test_allocator.h"
39 typedef test_less
<int> C
;
40 typedef test_allocator
<V
> A
;
41 std::multiset
<int, C
, A
> mo(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]), C(5), A(7));
42 std::multiset
<int, C
, A
> m
= mo
;
43 assert(m
.get_allocator() == A(7));
44 assert(m
.key_comp() == C(5));
45 assert(m
.size() == 9);
46 assert(std::distance(m
.begin(), m
.end()) == 9);
47 assert(*std::next(m
.begin(), 0) == 1);
48 assert(*std::next(m
.begin(), 1) == 1);
49 assert(*std::next(m
.begin(), 2) == 1);
50 assert(*std::next(m
.begin(), 3) == 2);
51 assert(*std::next(m
.begin(), 4) == 2);
52 assert(*std::next(m
.begin(), 5) == 2);
53 assert(*std::next(m
.begin(), 6) == 3);
54 assert(*std::next(m
.begin(), 7) == 3);
55 assert(*std::next(m
.begin(), 8) == 3);
57 assert(mo
.get_allocator() == A(7));
58 assert(mo
.key_comp() == C(5));
59 assert(mo
.size() == 9);
60 assert(std::distance(mo
.begin(), mo
.end()) == 9);
61 assert(*std::next(mo
.begin(), 0) == 1);
62 assert(*std::next(mo
.begin(), 1) == 1);
63 assert(*std::next(mo
.begin(), 2) == 1);
64 assert(*std::next(mo
.begin(), 3) == 2);
65 assert(*std::next(mo
.begin(), 4) == 2);
66 assert(*std::next(mo
.begin(), 5) == 2);
67 assert(*std::next(mo
.begin(), 6) == 3);
68 assert(*std::next(mo
.begin(), 7) == 3);
69 assert(*std::next(mo
.begin(), 8) == 3);
71 #if TEST_STD_VER >= 11
86 typedef test_less
<int> C
;
87 typedef other_allocator
<V
> A
;
88 std::multiset
<int, C
, A
> mo(ar
, ar
+sizeof(ar
)/sizeof(ar
[0]), C(5), A(7));
89 std::multiset
<int, C
, A
> m
= mo
;
90 assert(m
.get_allocator() == A(-2));
91 assert(m
.key_comp() == C(5));
92 assert(m
.size() == 9);
93 assert(std::distance(m
.begin(), m
.end()) == 9);
94 assert(*std::next(m
.begin(), 0) == 1);
95 assert(*std::next(m
.begin(), 1) == 1);
96 assert(*std::next(m
.begin(), 2) == 1);
97 assert(*std::next(m
.begin(), 3) == 2);
98 assert(*std::next(m
.begin(), 4) == 2);
99 assert(*std::next(m
.begin(), 5) == 2);
100 assert(*std::next(m
.begin(), 6) == 3);
101 assert(*std::next(m
.begin(), 7) == 3);
102 assert(*std::next(m
.begin(), 8) == 3);
104 assert(mo
.get_allocator() == A(7));
105 assert(mo
.key_comp() == C(5));
106 assert(mo
.size() == 9);
107 assert(std::distance(mo
.begin(), mo
.end()) == 9);
108 assert(*std::next(mo
.begin(), 0) == 1);
109 assert(*std::next(mo
.begin(), 1) == 1);
110 assert(*std::next(mo
.begin(), 2) == 1);
111 assert(*std::next(mo
.begin(), 3) == 2);
112 assert(*std::next(mo
.begin(), 4) == 2);
113 assert(*std::next(mo
.begin(), 5) == 2);
114 assert(*std::next(mo
.begin(), 6) == 3);
115 assert(*std::next(mo
.begin(), 7) == 3);
116 assert(*std::next(mo
.begin(), 8) == 3);