Skip to content

Commit

Permalink
Add constexpr sorting test
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickroberts committed Feb 8, 2025
1 parent 04a3096 commit e97b408
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/beman/any_view/constexpr.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

#include <beman/any_view/any_view.hpp>

#include "options.hpp"

#include <gtest/gtest.h>

#include <algorithm>
#include <vector>

using beman::any_view::any_view;
Expand Down Expand Up @@ -73,3 +76,16 @@ TEST(ConstexprTest, sum_transform_view_of_iota) {
#endif
EXPECT_EQ(35, sum(view));
}

constexpr auto sort(any_view<int, random_access_options> view) {
std::ranges::sort(view);
return std::ranges::is_sorted(view);
}

TEST(ConstexprTest, sort_vector) {
#ifdef __clang__
// ICE on GCC and MSVC
static_assert(sort(std::vector{6, 8, 7, 5, 3, 0, 9}));
#endif
EXPECT_TRUE(sort(std::vector{6, 8, 7, 5, 3, 0, 9}));
}

0 comments on commit e97b408

Please sign in to comment.