Skip to content

Commit e97b408

Browse files
Add constexpr sorting test
1 parent 04a3096 commit e97b408

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/beman/any_view/constexpr.test.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
#include <beman/any_view/any_view.hpp>
44

5+
#include "options.hpp"
6+
57
#include <gtest/gtest.h>
68

9+
#include <algorithm>
710
#include <vector>
811

912
using beman::any_view::any_view;
@@ -73,3 +76,16 @@ TEST(ConstexprTest, sum_transform_view_of_iota) {
7376
#endif
7477
EXPECT_EQ(35, sum(view));
7578
}
79+
80+
constexpr auto sort(any_view<int, random_access_options> view) {
81+
std::ranges::sort(view);
82+
return std::ranges::is_sorted(view);
83+
}
84+
85+
TEST(ConstexprTest, sort_vector) {
86+
#ifdef __clang__
87+
// ICE on GCC and MSVC
88+
static_assert(sort(std::vector{6, 8, 7, 5, 3, 0, 9}));
89+
#endif
90+
EXPECT_TRUE(sort(std::vector{6, 8, 7, 5, 3, 0, 9}));
91+
}

0 commit comments

Comments
 (0)