Skip to content

Commit 61f4722

Browse files
committed
more tests
1 parent 285a1e5 commit 61f4722

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/initializer_list.pass.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <functional>
2323
#include <type_traits>
2424
#include <vector>
25+
#include <ranges>
2526

2627
#include "test_macros.h"
2728
#include "min_allocator.h"
@@ -77,26 +78,26 @@ void test() {
7778
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, std::allocator<int>>);
7879
}
7980

80-
int expected[] = {1, 2, 3, 5};
81+
int expected[] = {1, 2, 2, 3, 3, 5};
8182
{
8283
// flat_multiset(initializer_list<value_type>);
8384
using M = std::flat_multiset<int>;
8485
std::initializer_list<int> il = {5, 2, 2, 3, 1, 3};
8586
M m(il);
86-
assert(std::equal(m.begin(), m.end(), expected, expected + 4));
87+
assert(std::ranges::equal(m, expected));
8788
}
8889
{
8990
// flat_multiset(initializer_list<value_type>);
9091
// explicit(false)
9192
using M = std::flat_multiset<int>;
9293
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));
9495
}
9596
{
9697
// flat_multiset(initializer_list<value_type>);
9798
using M = std::flat_multiset<int, std::greater<int>, std::deque<int, min_allocator<int>>>;
9899
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));
100101
}
101102
{
102103
using A = explicit_allocator<int>;
@@ -105,7 +106,7 @@ void test() {
105106
// different comparator
106107
using M = std::flat_multiset<int, DefaultCtableComp, std::vector<int, A>>;
107108
M m = {1, 2, 3};
108-
assert(m.size() == 1);
109+
assert(m.size() == 3);
109110
LIBCPP_ASSERT(*m.begin() == 1);
110111
assert(m.key_comp().default_constructed_);
111112
}
@@ -114,15 +115,15 @@ void test() {
114115
using M = std::flat_multiset<int, std::greater<int>, std::deque<int, A>>;
115116
A a;
116117
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));
118119
}
119120
}
120121
{
121122
// flat_multiset(initializer_list<value_type>, const key_compare&);
122123
using C = test_less<int>;
123124
using M = std::flat_multiset<int, C>;
124125
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));
126127
assert(m.key_comp() == C(10));
127128

128129
// explicit(false)
@@ -134,8 +135,8 @@ void test() {
134135
// flat_multiset(initializer_list<value_type>, const key_compare&);
135136
// Sorting uses the comparator that was passed in
136137
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));
139140
assert(m.key_comp()(2, 1) == true);
140141
}
141142
{
@@ -144,7 +145,7 @@ void test() {
144145
using M = std::flat_multiset<int, std::greater<int>, std::deque<int, A>>;
145146
A a;
146147
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));
148149
}
149150
}
150151

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/iter_iter.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <deque>
2222
#include <flat_set>
2323
#include <functional>
24+
#include <ranges>
2425
#include <vector>
2526

2627
#include "min_allocator.h"
@@ -55,7 +56,7 @@ void test() {
5556
}
5657

5758
int ar[] = {1, 1, 1, 2, 2, 3, 2, 3, 3};
58-
int expected[] = {1, 2, 3};
59+
int expected[] = {1, 1,1,2,2,2,3,3,3};
5960
{
6061
// flat_multiset(InputIterator , InputIterator)
6162
// cpp17_input_iterator
@@ -72,7 +73,7 @@ void test() {
7273
// greater
7374
using M = std::flat_multiset<int, std::greater<int>, std::deque<int, min_allocator<int>>>;
7475
auto m = M(cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 9));
75-
assert(std::ranges::equal(m, std::deque<int, min_allocator<int>>{3, 2, 1}));
76+
assert(std::ranges::equal(m, expected | std::views::reverse));
7677
}
7778
{
7879
// flat_multiset(InputIterator , InputIterator)

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move_alloc.pass.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ void test() {
4242
static_assert(!std::is_constructible_v<M2, M2&&, const A1&>);
4343
}
4444
{
45-
int expected[] = {1, 2, 3};
45+
int expected[] = {1, 1, 2, 2, 3};
4646
using C = test_less<int>;
4747
using A = test_allocator<int>;
4848
using M = std::flat_multiset<int, C, std::deque<int, A>>;
49-
auto mo = M(expected, expected + 3, C(5), A(7));
49+
auto mo = M(expected, expected + 5, C(5), A(7));
5050
auto m = M(std::move(mo), A(3));
5151

5252
assert(m.key_comp() == C(5));
53-
assert(m.size() == 3);
53+
assert(m.size() == 5);
5454
auto keys = std::move(m).extract();
5555
assert(keys.get_allocator() == A(3));
5656
assert(std::ranges::equal(keys, expected));
@@ -64,10 +64,10 @@ void test() {
6464
{
6565
// moved-from object maintains invariant if one of underlying container does not clear after move
6666
using M = std::flat_multiset<int, std::less<>, CopyOnlyVector<int>>;
67-
M m1 = M({1, 2, 3});
67+
M m1 = M({1, 2, 2, 1, 3});
6868
M m2(std::move(m1), std::allocator<int>{});
69-
assert(m2.size() == 3);
70-
check_invariant(m1);
69+
assert(m2.size() == 5);
70+
assert(std::ranges::is_sorted(m1));
7171
LIBCPP_ASSERT(m1.empty());
7272
}
7373
}

0 commit comments

Comments
 (0)