[libcxx-commits] [libcxx] [libc++][test] Refactor tests for std::{copy, move, fill} algorithms (PR #120909)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Dec 22 08:46:58 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Peng Liu (winner245)
<details>
<summary>Changes</summary>
This refactor includes the following changes:
- Rewirte similar tests using `type_algorithms.h` utilities to reduce reduandant code;
- Factor out common headers;
- Avoid transitive inclusion of `type_algorithms.h`
The purpose of this refactoring is to facilitate subsequent work to optimize the algorithms for `vector<bool>::iterator`.
---
Patch is 37.53 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/120909.diff
14 Files Affected:
- (added) libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/common.h (+30)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp (+23-30)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp (+31-56)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp (+28-55)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp (+35-70)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/pstl.copy.pass.cpp (+1)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/pstl.copy_n.pass.cpp (+2-1)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp (+1)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp (+95-118)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/pstl.fill.pass.cpp (+1)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/pstl.fill_n.pass.cpp (+1)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp (+49-60)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp (+52-66)
- (modified) libcxx/test/std/algorithms/alg.modifying.operations/alg.move/pstl.move.pass.cpp (+1)
``````````diff
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/common.h b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/common.h
new file mode 100644
index 00000000000000..562ae5121e4287
--- /dev/null
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/common.h
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_STD_ALGORITHMS_ALG_MODIFYING_OPERATIONS_ALG_COPY_COMMON_H
+#define TEST_STD_ALGORITHMS_ALG_MODIFYING_OPERATIONS_ALG_COPY_COMMON_H
+
+#include <cstdint>
+#include "test_macros.h"
+
+class PaddedBase {
+public:
+ TEST_CONSTEXPR PaddedBase(std::int16_t a, std::int8_t b) : a_(a), b_(b) {}
+
+ std::int16_t a_;
+ std::int8_t b_;
+};
+
+class Derived : public PaddedBase {
+public:
+ TEST_CONSTEXPR Derived(std::int16_t a, std::int8_t b, std::int8_t c) : PaddedBase(a, b), c_(c) {}
+
+ std::int8_t c_;
+};
+
+#endif
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
index b5f0a32b986a03..e781feacb8bd93 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
@@ -15,23 +15,30 @@
#include <algorithm>
#include <cassert>
+#include "common.h"
#include "test_macros.h"
#include "test_iterators.h"
+#include "type_algorithms.h"
-class PaddedBase {
-public:
- TEST_CONSTEXPR PaddedBase(std::int16_t a, std::int8_t b) : a_(a), b_(b) {}
-
- std::int16_t a_;
- std::int8_t b_;
-};
-
-class Derived : public PaddedBase {
-public:
- TEST_CONSTEXPR Derived(std::int16_t a, std::int8_t b, std::int8_t c) : PaddedBase(a, b), c_(c) {}
+TEST_CONSTEXPR_CXX20 void test_padding() {
+ { // Make sure that padding bits aren't copied
+ Derived src(1, 2, 3);
+ Derived dst(4, 5, 6);
+ std::copy(static_cast<PaddedBase*>(&src), static_cast<PaddedBase*>(&src) + 1, static_cast<PaddedBase*>(&dst));
+ assert(dst.a_ == 1);
+ assert(dst.b_ == 2);
+ assert(dst.c_ == 6);
+ }
+}
- std::int8_t c_;
-};
+TEST_CONSTEXPR_CXX20 void test_overlapping() {
+ { // Make sure that overlapping ranges can be copied
+ int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ std::copy(a + 3, a + 10, a);
+ int expected[] = {4, 5, 6, 7, 8, 9, 10, 8, 9, 10};
+ assert(std::equal(a, a + 10, expected));
+ }
+}
template <class InIter>
struct Test {
@@ -60,23 +67,9 @@ struct TestInIters {
};
TEST_CONSTEXPR_CXX20 bool test() {
- types::for_each(types::cpp17_input_iterator_list<int*>(), TestInIters());
-
- { // Make sure that padding bits aren't copied
- Derived src(1, 2, 3);
- Derived dst(4, 5, 6);
- std::copy(static_cast<PaddedBase*>(&src), static_cast<PaddedBase*>(&src) + 1, static_cast<PaddedBase*>(&dst));
- assert(dst.a_ == 1);
- assert(dst.b_ == 2);
- assert(dst.c_ == 6);
- }
-
- { // Make sure that overlapping ranges can be copied
- int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- std::copy(a + 3, a + 10, a);
- int expected[] = {4, 5, 6, 7, 8, 9, 10, 8, 9, 10};
- assert(std::equal(a, a + 10, expected));
- }
+ types::for_each(types::cpp17_input_iterator_list<const int*>(), TestInIters());
+ test_padding();
+ test_overlapping();
return true;
}
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
index 928903de1ade2d..3629da78cbcc6a 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
@@ -16,69 +16,30 @@
#include <algorithm>
#include <cassert>
+#include "common.h"
#include "test_macros.h"
#include "test_iterators.h"
+#include "type_algorithms.h"
#include "user_defined_integral.h"
-class PaddedBase {
-public:
- TEST_CONSTEXPR PaddedBase(std::int16_t a, std::int8_t b) : a_(a), b_(b) {}
-
- std::int16_t a_;
- std::int8_t b_;
-};
-
-class Derived : public PaddedBase {
-public:
- TEST_CONSTEXPR Derived(std::int16_t a, std::int8_t b, std::int8_t c) : PaddedBase(a, b), c_(c) {}
-
- std::int8_t c_;
-};
-
-template <class InIter, class OutIter>
-TEST_CONSTEXPR_CXX20 void
-test_copy_backward()
-{
- {
+template <class InIter>
+struct TestOutIters {
+ template <class OutIter>
+ TEST_CONSTEXPR_CXX20 void operator()() {
const unsigned N = 1000;
- int ia[N] = {};
+ int ia[N] = {};
for (unsigned i = 0; i < N; ++i)
- ia[i] = i;
+ ia[i] = i;
int ib[N] = {0};
- OutIter r = std::copy_backward(InIter(ia), InIter(ia+N), OutIter(ib+N));
+ OutIter r = std::copy_backward(InIter(ia), InIter(ia + N), OutIter(ib + N));
assert(base(r) == ib);
for (unsigned i = 0; i < N; ++i)
- assert(ia[i] == ib[i]);
+ assert(ia[i] == ib[i]);
}
-}
-
-TEST_CONSTEXPR_CXX20 bool
-test()
-{
- test_copy_backward<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
- test_copy_backward<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
- test_copy_backward<bidirectional_iterator<const int*>, int*>();
-
- test_copy_backward<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
- test_copy_backward<random_access_iterator<const int*>, random_access_iterator<int*> >();
- test_copy_backward<random_access_iterator<const int*>, int*>();
-
- test_copy_backward<const int*, bidirectional_iterator<int*> >();
- test_copy_backward<const int*, random_access_iterator<int*> >();
- test_copy_backward<const int*, int*>();
-
-#if TEST_STD_VER > 17
- test_copy_backward<contiguous_iterator<const int*>, bidirectional_iterator<int*>>();
- test_copy_backward<contiguous_iterator<const int*>, random_access_iterator<int*>>();
- test_copy_backward<contiguous_iterator<const int*>, int*>();
-
- test_copy_backward<bidirectional_iterator<const int*>, contiguous_iterator<int*>>();
- test_copy_backward<random_access_iterator<const int*>, contiguous_iterator<int*>>();
- test_copy_backward<contiguous_iterator<const int*>, contiguous_iterator<int*>>();
- test_copy_backward<const int*, contiguous_iterator<int*>>();
-#endif
+};
+TEST_CONSTEXPR_CXX20 void test_padding() {
{ // Make sure that padding bits aren't copied
Derived src(1, 2, 3);
Derived dst(4, 5, 6);
@@ -88,23 +49,37 @@ test()
assert(dst.b_ == 2);
assert(dst.c_ == 6);
}
+}
+TEST_CONSTEXPR_CXX20 void test_overlapping() {
{ // Make sure that overlapping ranges can be copied
int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
std::copy_backward(a, a + 7, a + 10);
int expected[] = {1, 2, 3, 1, 2, 3, 4, 5, 6, 7};
assert(std::equal(a, a + 10, expected));
}
+}
+
+struct TestInIters {
+ template <class InIter>
+ TEST_CONSTEXPR_CXX20 void operator()() {
+ types::for_each(types::bidirectional_iterator_list<int*>(), TestOutIters<InIter>());
+ }
+};
+
+TEST_CONSTEXPR_CXX20 bool test() {
+ types::for_each(types::bidirectional_iterator_list<const int*>(), TestInIters());
+ test_padding();
+ test_overlapping();
- return true;
+ return true;
}
-int main(int, char**)
-{
- test();
+int main(int, char**) {
+ test();
#if TEST_STD_VER > 17
- static_assert(test());
+ static_assert(test());
#endif
return 0;
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
index 57214e65455b45..3bee77738e3423 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
@@ -19,75 +19,48 @@
#include "test_macros.h"
#include "test_iterators.h"
+#include "type_algorithms.h"
-struct Pred
-{
- TEST_CONSTEXPR_CXX14 bool operator()(int i) {return i % 3 == 0;}
+struct Pred {
+ TEST_CONSTEXPR_CXX14 bool operator()(int i) { return i % 3 == 0; }
};
-template <class InIter, class OutIter>
-TEST_CONSTEXPR_CXX20 void
-test_copy_if()
-{
+template <class InIter>
+struct TestOutIters {
+ template <class OutIter>
+ TEST_CONSTEXPR_CXX20 void operator()() {
const unsigned N = 1000;
- int ia[N] = {};
+ int ia[N] = {};
for (unsigned i = 0; i < N; ++i)
- ia[i] = i;
+ ia[i] = i;
int ib[N] = {0};
- OutIter r = std::copy_if(InIter(ia), InIter(ia+N), OutIter(ib), Pred());
- assert(base(r) == ib+N/3+1);
- for (unsigned i = 0; i < N/3+1; ++i)
- assert(ib[i] % 3 == 0);
-}
-
-TEST_CONSTEXPR_CXX20 bool
-test()
-{
- test_copy_if<cpp17_input_iterator<const int*>, cpp17_output_iterator<int*> >();
- test_copy_if<cpp17_input_iterator<const int*>, cpp17_input_iterator<int*> >();
- test_copy_if<cpp17_input_iterator<const int*>, forward_iterator<int*> >();
- test_copy_if<cpp17_input_iterator<const int*>, bidirectional_iterator<int*> >();
- test_copy_if<cpp17_input_iterator<const int*>, random_access_iterator<int*> >();
- test_copy_if<cpp17_input_iterator<const int*>, int*>();
-
- test_copy_if<forward_iterator<const int*>, cpp17_output_iterator<int*> >();
- test_copy_if<forward_iterator<const int*>, cpp17_input_iterator<int*> >();
- test_copy_if<forward_iterator<const int*>, forward_iterator<int*> >();
- test_copy_if<forward_iterator<const int*>, bidirectional_iterator<int*> >();
- test_copy_if<forward_iterator<const int*>, random_access_iterator<int*> >();
- test_copy_if<forward_iterator<const int*>, int*>();
-
- test_copy_if<bidirectional_iterator<const int*>, cpp17_output_iterator<int*> >();
- test_copy_if<bidirectional_iterator<const int*>, cpp17_input_iterator<int*> >();
- test_copy_if<bidirectional_iterator<const int*>, forward_iterator<int*> >();
- test_copy_if<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
- test_copy_if<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
- test_copy_if<bidirectional_iterator<const int*>, int*>();
-
- test_copy_if<random_access_iterator<const int*>, cpp17_output_iterator<int*> >();
- test_copy_if<random_access_iterator<const int*>, cpp17_input_iterator<int*> >();
- test_copy_if<random_access_iterator<const int*>, forward_iterator<int*> >();
- test_copy_if<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
- test_copy_if<random_access_iterator<const int*>, random_access_iterator<int*> >();
- test_copy_if<random_access_iterator<const int*>, int*>();
+ OutIter r = std::copy_if(InIter(ia), InIter(ia + N), OutIter(ib), Pred());
+ assert(base(r) == ib + N / 3 + 1);
+ for (unsigned i = 0; i < N / 3 + 1; ++i)
+ assert(ib[i] % 3 == 0);
+ }
+};
- test_copy_if<const int*, cpp17_output_iterator<int*> >();
- test_copy_if<const int*, cpp17_input_iterator<int*> >();
- test_copy_if<const int*, forward_iterator<int*> >();
- test_copy_if<const int*, bidirectional_iterator<int*> >();
- test_copy_if<const int*, random_access_iterator<int*> >();
- test_copy_if<const int*, int*>();
+struct TestInIters {
+ template <class InIter>
+ TEST_CONSTEXPR_CXX20 void operator()() {
+ types::for_each(
+ types::concatenate_t<types::cpp17_input_iterator_list<int*>, types::type_list<cpp17_output_iterator<int*> > >(),
+ TestOutIters<InIter>());
+ }
+};
+TEST_CONSTEXPR_CXX20 bool test() {
+ types::for_each(types::cpp17_input_iterator_list<const int*>(), TestInIters());
return true;
}
-int main(int, char**)
-{
- test();
+int main(int, char**) {
+ test();
#if TEST_STD_VER > 17
- static_assert(test());
+ static_assert(test());
#endif
return 0;
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
index b0acc1060101c2..28362f4f990997 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
@@ -15,44 +15,15 @@
#include <algorithm>
#include <cassert>
+#include "common.h"
#include "test_macros.h"
#include "test_iterators.h"
+#include "type_algorithms.h"
#include "user_defined_integral.h"
typedef UserDefinedIntegral<unsigned> UDI;
-class PaddedBase {
-public:
- TEST_CONSTEXPR PaddedBase(std::int16_t a, std::int8_t b) : a_(a), b_(b) {}
-
- std::int16_t a_;
- std::int8_t b_;
-};
-
-class Derived : public PaddedBase {
-public:
- TEST_CONSTEXPR Derived(std::int16_t a, std::int8_t b, std::int8_t c) : PaddedBase(a, b), c_(c) {}
-
- std::int8_t c_;
-};
-
-template <class InIter, class OutIter>
-TEST_CONSTEXPR_CXX20 void
-test_copy_n()
-{
- {
- const unsigned N = 1000;
- int ia[N] = {};
- for (unsigned i = 0; i < N; ++i)
- ia[i] = i;
- int ib[N] = {0};
-
- OutIter r = std::copy_n(InIter(ia), UDI(N/2), OutIter(ib));
- assert(base(r) == ib+N/2);
- for (unsigned i = 0; i < N/2; ++i)
- assert(ia[i] == ib[i]);
- }
-
+TEST_CONSTEXPR_CXX20 void test_padding() {
{ // Make sure that padding bits aren't copied
Derived src(1, 2, 3);
Derived dst(4, 5, 6);
@@ -61,7 +32,9 @@ test_copy_n()
assert(dst.b_ == 2);
assert(dst.c_ == 6);
}
+}
+TEST_CONSTEXPR_CXX20 void test_overlapping() {
{ // Make sure that overlapping ranges can be copied
int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
std::copy_n(a + 3, 7, a);
@@ -70,53 +43,45 @@ test_copy_n()
}
}
-TEST_CONSTEXPR_CXX20 bool
-test()
-{
- test_copy_n<cpp17_input_iterator<const int*>, cpp17_output_iterator<int*> >();
- test_copy_n<cpp17_input_iterator<const int*>, cpp17_input_iterator<int*> >();
- test_copy_n<cpp17_input_iterator<const int*>, forward_iterator<int*> >();
- test_copy_n<cpp17_input_iterator<const int*>, bidirectional_iterator<int*> >();
- test_copy_n<cpp17_input_iterator<const int*>, random_access_iterator<int*> >();
- test_copy_n<cpp17_input_iterator<const int*>, int*>();
-
- test_copy_n<forward_iterator<const int*>, cpp17_output_iterator<int*> >();
- test_copy_n<forward_iterator<const int*>, cpp17_input_iterator<int*> >();
- test_copy_n<forward_iterator<const int*>, forward_iterator<int*> >();
- test_copy_n<forward_iterator<const int*>, bidirectional_iterator<int*> >();
- test_copy_n<forward_iterator<const int*>, random_access_iterator<int*> >();
- test_copy_n<forward_iterator<const int*>, int*>();
+template <class InIter>
+struct TestOutIters {
+ template <class OutIter>
+ TEST_CONSTEXPR_CXX20 void operator()() {
+ const unsigned N = 1000;
+ int ia[N] = {};
+ for (unsigned i = 0; i < N; ++i)
+ ia[i] = i;
+ int ib[N] = {0};
- test_copy_n<bidirectional_iterator<const int*>, cpp17_output_iterator<int*> >();
- test_copy_n<bidirectional_iterator<const int*>, cpp17_input_iterator<int*> >();
- test_copy_n<bidirectional_iterator<const int*>, forward_iterator<int*> >();
- test_copy_n<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
- test_copy_n<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
- test_copy_n<bidirectional_iterator<const int*>, int*>();
+ OutIter r = std::copy_n(InIter(ia), UDI(N / 2), OutIter(ib));
+ assert(base(r) == ib + N / 2);
+ for (unsigned i = 0; i < N / 2; ++i)
+ assert(ia[i] == ib[i]);
+ }
+};
- test_copy_n<random_access_iterator<const int*>, cpp17_output_iterator<int*> >();
- test_copy_n<random_access_iterator<const int*>, cpp17_input_iterator<int*> >();
- test_copy_n<random_access_iterator<const int*>, forward_iterator<int*> >();
- test_copy_n<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
- test_copy_n<random_access_iterator<const int*>, random_access_iterator<int*> >();
- test_copy_n<random_access_iterator<const int*>, int*>();
+struct TestInIters {
+ template <class InIter>
+ TEST_CONSTEXPR_CXX20 void operator()() {
+ types::for_each(
+ types::concatenate_t<types::cpp17_input_iterator_list<int*>, types::type_list<cpp17_output_iterator<int*> > >(),
+ TestOutIters<InIter>());
+ }
+};
- test_copy_n<const int*, cpp17_output_iterator<int*> >();
- test_copy_n<const int*, cpp17_input_iterator<int*> >();
- test_copy_n<const int*, forward_iterator<int*> >();
- test_copy_n<const int*, bidirectional_iterator<int*> >();
- test_copy_n<const int*, random_access_iterator<int*> >();
- test_copy_n<const int*, int*>();
+TEST_CONSTEXPR_CXX20 bool test() {
+ types::for_each(types::cpp17_input_iterator_list<const int*>(), TestInIters());
+ test_padding();
+ test_overlapping();
return true;
}
-int main(int, char**)
-{
- test();
+int main(int, char**) {
+ test();
#if TEST_STD_VER > 17
- static_assert(test());
+ static_assert(test());
#endif
return 0;
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/pstl.copy.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/pstl.copy.pass.cpp
index bee1ef9bcec332..6229aac733a9c4 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/pstl.copy.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/pstl.copy.pass.cpp
@@ -23,6 +23,7 @@
#include "test_macros.h"
#include "test_execution_policies.h"
#include "test_iterators.h"
+#include "type_algorithms.h"
EXECUTION_POLICY_SFINAE_TEST(copy);
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/pstl.copy_n.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/pstl.copy_n.pass.cpp
index 128108ac13811b..7208be75c70d03 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/pstl.copy_n.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/pstl.copy_n.pass.cpp
@@ -23,6 +23,7 @@
#include "test_macros.h"
#include "test_execution_policies.h"
#include "test_iterators.h"
+#include "type_algorithms.h"
EXECUTION_POLICY_SFINAE_TEST(copy_n);
@@ -58,7 +59,7 @@ struct TestIteratorsInt {
};
struct CopiedToTester {
- bool copied_to = false;
+ bool copied_to = false;
CopiedToTester() = default;
CopiedToTester(const CopiedToTester&) {}
CopiedToTester& operator=(const CopiedToTester&) {
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp
index 619dc7242a3660..46b33d1727a716 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp
@@ -21,6 +21,7 @@
#include "test_macros.h"
#include "test_iterators.h"
+#include "type_algorithms.h"
template <class Iter, class Container>
TEST_CONSTEXPR_CXX20 void
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
index 7d6770de702bf3..10ec4fee6315ba 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
@@ -14,160 +14,137 @@
// fill_n(Iter first, Size n, const T& value);
#include <algorithm>
+#include <array>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
+#include "type_algorithms.h"
#include "user_defined_integral.h"
-#if TEST_STD_VER > 17
-TEST_CONSTEXPR bool test_constexpr() {
- const std::size_t N = 5;
- int ib[] = {0, 0, 0, 0, 0, 0}; // one bigger than N
-
- auto it = std::fill_n(std::begin(ib), N, 5);
- return it == (std::begin(ib) + N)
- && std::all_of(std::begin(ib), it, [](int a) {return a == 5; })
- && *it == 0 // don't overwrite the last value in the output array
- ;
- }
-#endif
-
typedef UserDefinedIntegral<unsigned> UDI;
-template <class Iter>
-void
-test_char()
-{
- char a[4] = {};
- Iter it...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/120909
More information about the libcxx-commits
mailing list