Skip to content

Commit 69d709f

Browse files
committed
Introduce a single top-level test() function
1 parent 4955fb0 commit 69d709f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

libcxx/test/std/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <cassert>
1919
#include <memory>
2020
#include <utility>
21+
#include <__type_traits/is_constant_evaluated.h>
2122

2223
#include "test_macros.h"
2324
#include "test_iterators.h"
@@ -67,12 +68,6 @@ struct TestUniquePtr {
6768
}
6869
};
6970
};
70-
71-
// This test is constexpr only since C++23 because constexpr std::unique_ptr is only available since C++23
72-
TEST_CONSTEXPR_CXX23 bool test_unique_ptr() {
73-
types::for_each(types::forward_iterator_list<std::unique_ptr<int>*>(), TestUniquePtr());
74-
return true;
75-
}
7671
#endif
7772

7873
TEST_CONSTEXPR_CXX20 bool test_simple_cases() {
@@ -104,20 +99,25 @@ TEST_CONSTEXPR_CXX20 bool test_simple_cases() {
10499
TEST_CONSTEXPR_CXX20 bool test() {
105100
test_simple_cases();
106101
types::for_each(types::forward_iterator_list<int*>(), TestPtr());
102+
103+
if (std::__libcpp_is_constant_evaluated()) {
104+
#if TEST_STD_VER >= 23
105+
types::for_each(types::forward_iterator_list<std::unique_ptr<int>*>(), TestUniquePtr());
106+
#endif
107+
} else {
108+
#if TEST_STD_VER >= 11
109+
types::for_each(types::forward_iterator_list<std::unique_ptr<int>*>(), TestUniquePtr());
110+
#endif
111+
}
112+
107113
return true;
108114
}
109115

110116
int main(int, char**) {
111117
test();
112-
#if TEST_STD_VER >= 11
113-
test_unique_ptr();
114-
#endif
115118
#if TEST_STD_VER >= 20
116119
static_assert(test());
117120
#endif
118-
#if TEST_STD_VER >= 23
119-
static_assert(test_unique_ptr());
120-
#endif
121121

122122
return 0;
123123
}

0 commit comments

Comments
 (0)