Skip to content

Commit 3fd3244

Browse files
committed
Intentionally invokes standard std::equal in fill, fill_n tests
1 parent 350b932 commit 3fd3244

File tree

4 files changed

+64
-8
lines changed

4 files changed

+64
-8
lines changed

libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,28 @@ TEST_CONSTEXPR_CXX20 void test_bititer_with_custom_sized_types() {
5555
std::vector<bool, Alloc> in(100, false, Alloc(1));
5656
std::vector<bool, Alloc> expected(100, true, Alloc(1));
5757
std::fill(in.begin(), in.end(), true);
58-
assert(in == expected);
58+
59+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
60+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
61+
assert(
62+
in.size() == expected.size() &&
63+
std::equal(
64+
cpp17_input_iterator(in.begin()), cpp17_input_iterator(in.end()), cpp17_input_iterator(expected.begin())));
65+
// assert(in == expected);
5966
}
6067
{
6168
using Alloc = sized_allocator<bool, std::uint16_t, std::int16_t>;
6269
std::vector<bool, Alloc> in(200, false, Alloc(1));
6370
std::vector<bool, Alloc> expected(200, true, Alloc(1));
6471
std::fill(in.begin(), in.end(), true);
65-
assert(in == expected);
72+
73+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
74+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
75+
assert(
76+
in.size() == expected.size() &&
77+
std::equal(
78+
cpp17_input_iterator(in.begin()), cpp17_input_iterator(in.end()), cpp17_input_iterator(expected.begin())));
79+
// assert(in == expected);
6680
}
6781
{
6882
using Alloc = sized_allocator<bool, std::uint32_t, std::int32_t>;

libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,28 @@ TEST_CONSTEXPR_CXX20 void test_bititer_with_custom_sized_types() {
137137
std::vector<bool, Alloc> in(100, false, Alloc(1));
138138
std::vector<bool, Alloc> expected(100, true, Alloc(1));
139139
std::fill_n(in.begin(), in.size(), true);
140-
assert(in == expected);
140+
141+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
142+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
143+
assert(
144+
in.size() == expected.size() &&
145+
std::equal(
146+
cpp17_input_iterator(in.begin()), cpp17_input_iterator(in.end()), cpp17_input_iterator(expected.begin())));
147+
// assert(in == expected);
141148
}
142149
{
143150
using Alloc = sized_allocator<bool, std::uint16_t, std::int16_t>;
144151
std::vector<bool, Alloc> in(200, false, Alloc(1));
145152
std::vector<bool, Alloc> expected(200, true, Alloc(1));
146153
std::fill_n(in.begin(), in.size(), true);
147-
assert(in == expected);
154+
155+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
156+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
157+
assert(
158+
in.size() == expected.size() &&
159+
std::equal(
160+
cpp17_input_iterator(in.begin()), cpp17_input_iterator(in.end()), cpp17_input_iterator(expected.begin())));
161+
// assert(in == expected);
148162
}
149163
{
150164
using Alloc = sized_allocator<bool, std::uint32_t, std::int32_t>;

libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/ranges.fill.pass.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,28 @@ TEST_CONSTEXPR_CXX20 void test_bititer_with_custom_sized_types() {
9191
std::vector<bool, Alloc> in(100, false, Alloc(1));
9292
std::vector<bool, Alloc> expected(100, true, Alloc(1));
9393
std::ranges::fill(in, true);
94-
assert(in == expected);
94+
95+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
96+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
97+
assert(
98+
in.size() == expected.size() &&
99+
std::equal(
100+
cpp17_input_iterator(in.begin()), cpp17_input_iterator(in.end()), cpp17_input_iterator(expected.begin())));
101+
// assert(in == expected);
95102
}
96103
{
97104
using Alloc = sized_allocator<bool, std::uint16_t, std::int16_t>;
98105
std::vector<bool, Alloc> in(200, false, Alloc(1));
99106
std::vector<bool, Alloc> expected(200, true, Alloc(1));
100107
std::ranges::fill(in, true);
101-
assert(in == expected);
108+
109+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
110+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
111+
assert(
112+
in.size() == expected.size() &&
113+
std::equal(
114+
cpp17_input_iterator(in.begin()), cpp17_input_iterator(in.end()), cpp17_input_iterator(expected.begin())));
115+
// assert(in == expected);
102116
}
103117
{
104118
using Alloc = sized_allocator<bool, std::uint32_t, std::int32_t>;

libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/ranges.fill_n.pass.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,28 @@ TEST_CONSTEXPR_CXX20 void test_bititer_with_custom_sized_types() {
6464
std::vector<bool, Alloc> in(100, false, Alloc(1));
6565
std::vector<bool, Alloc> expected(100, true, Alloc(1));
6666
std::ranges::fill_n(std::ranges::begin(in), in.size(), true);
67-
assert(in == expected);
67+
68+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
69+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
70+
assert(
71+
in.size() == expected.size() &&
72+
std::equal(
73+
cpp17_input_iterator(in.begin()), cpp17_input_iterator(in.end()), cpp17_input_iterator(expected.begin())));
74+
// assert(in == expected);
6875
}
6976
{
7077
using Alloc = sized_allocator<bool, std::uint16_t, std::int16_t>;
7178
std::vector<bool, Alloc> in(200, false, Alloc(1));
7279
std::vector<bool, Alloc> expected(200, true, Alloc(1));
7380
std::ranges::fill_n(std::ranges::begin(in), in.size(), true);
74-
assert(in == expected);
81+
82+
// FIXME: Force to call standard-form std::equal() instead of the vector<bool> optimization because the latter
83+
// suffers from UB for small integral `size_type`s, which will be fixed soon.
84+
assert(
85+
in.size() == expected.size() &&
86+
std::equal(
87+
cpp17_input_iterator(in.begin()), cpp17_input_iterator(in.end()), cpp17_input_iterator(expected.begin())));
88+
// assert(in == expected);
7589
}
7690
{
7791
using Alloc = sized_allocator<bool, std::uint32_t, std::int32_t>;

0 commit comments

Comments
 (0)