22
22
#include < functional>
23
23
#include < type_traits>
24
24
#include < vector>
25
+ #include < ranges>
25
26
26
27
#include " test_macros.h"
27
28
#include " min_allocator.h"
@@ -77,26 +78,26 @@ void test() {
77
78
static_assert (!std::is_constructible_v<M, std::initializer_list<const int >, std::allocator<int >>);
78
79
}
79
80
80
- int expected[] = {1 , 2 , 3 , 5 };
81
+ int expected[] = {1 , 2 , 2 , 3 , 3 , 5 };
81
82
{
82
83
// flat_multiset(initializer_list<value_type>);
83
84
using M = std::flat_multiset<int >;
84
85
std::initializer_list<int > il = {5 , 2 , 2 , 3 , 1 , 3 };
85
86
M m (il);
86
- assert (std::equal (m. begin (), m. end (), expected, expected + 4 ));
87
+ assert (std::ranges:: equal (m, expected));
87
88
}
88
89
{
89
90
// flat_multiset(initializer_list<value_type>);
90
91
// explicit(false)
91
92
using M = std::flat_multiset<int >;
92
93
M m = {5 , 2 , 2 , 3 , 1 , 3 };
93
- assert (std::equal (m. begin (), m. end (), expected, expected + 4 ));
94
+ assert (std::ranges:: equal (m, expected));
94
95
}
95
96
{
96
97
// flat_multiset(initializer_list<value_type>);
97
98
using M = std::flat_multiset<int , std::greater<int >, std::deque<int , min_allocator<int >>>;
98
99
M m = {5 , 2 , 2 , 3 , 1 , 3 };
99
- assert (std::equal (m. rbegin (), m. rend (), expected, expected + 4 ));
100
+ assert (std::ranges:: equal (m, expected | std::views::reverse ));
100
101
}
101
102
{
102
103
using A = explicit_allocator<int >;
@@ -105,7 +106,7 @@ void test() {
105
106
// different comparator
106
107
using M = std::flat_multiset<int , DefaultCtableComp, std::vector<int , A>>;
107
108
M m = {1 , 2 , 3 };
108
- assert (m.size () == 1 );
109
+ assert (m.size () == 3 );
109
110
LIBCPP_ASSERT (*m.begin () == 1 );
110
111
assert (m.key_comp ().default_constructed_ );
111
112
}
@@ -114,15 +115,15 @@ void test() {
114
115
using M = std::flat_multiset<int , std::greater<int >, std::deque<int , A>>;
115
116
A a;
116
117
M m ({5 , 2 , 2 , 3 , 1 , 3 }, a);
117
- assert (std::equal (m. rbegin (), m. rend (), expected, expected + 4 ));
118
+ assert (std::ranges:: equal (m, expected | std::views::reverse ));
118
119
}
119
120
}
120
121
{
121
122
// flat_multiset(initializer_list<value_type>, const key_compare&);
122
123
using C = test_less<int >;
123
124
using M = std::flat_multiset<int , C>;
124
125
auto m = M ({5 , 2 , 2 , 3 , 1 , 3 }, C (10 ));
125
- assert (std::equal (m. begin (), m. end (), expected, expected + 4 ));
126
+ assert (std::ranges:: equal (m, expected));
126
127
assert (m.key_comp () == C (10 ));
127
128
128
129
// explicit(false)
@@ -134,8 +135,8 @@ void test() {
134
135
// flat_multiset(initializer_list<value_type>, const key_compare&);
135
136
// Sorting uses the comparator that was passed in
136
137
using M = std::flat_multiset<int , std::function<bool (int , int )>, std::deque<int , min_allocator<int >>>;
137
- auto m = M ({5 , 2 , 2 , 1 , 3 , 1 }, std::greater<int >());
138
- assert (std::equal (m. rbegin (), m. rend (), expected, expected + 4 ));
138
+ auto m = M ({5 , 2 , 2 , 1 , 3 , 3 }, std::greater<int >());
139
+ assert (std::ranges:: equal (m, expected | std::views::reverse ));
139
140
assert (m.key_comp ()(2 , 1 ) == true );
140
141
}
141
142
{
@@ -144,7 +145,7 @@ void test() {
144
145
using M = std::flat_multiset<int , std::greater<int >, std::deque<int , A>>;
145
146
A a;
146
147
M m ({5 , 2 , 2 , 3 , 1 , 3 }, {}, a);
147
- assert (std::equal (m. rbegin (), m. rend (), expected, expected + 4 ));
148
+ assert (std::ranges:: equal (m, expected | std::views::reverse ));
148
149
}
149
150
}
150
151
0 commit comments