/
every_adapter_constexpr.cpp
36 lines (34 loc) · 1.16 KB
/
every_adapter_constexpr.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* Copyright (c) 2022-2024 Morwenn
* SPDX-License-Identifier: MIT
*/
#include <cstddef>
#include <catch2/catch_template_test_macros.hpp>
#include <cpp-sort/adapters.h>
#include <cpp-sort/sorters/insertion_sorter.h>
#include <testing-tools/algorithm.h>
namespace
{
template<typename Sorter>
constexpr auto test_constexpr_sorter()
-> bool
{
constexpr std::size_t size = 60;
int collection[size] = {
15, 6, 0, 2, 2, 3, 8, 12, 10, 5, 9, 7, 10, 45, 18,
15, 6, 0, 2, 2, 3, 8, 12, 10, 5, 9, 7, 10, 45, 18,
15, 6, 0, 2, 2, 3, 8, 12, 10, 5, 9, 7, 10, 45, 18,
15, 6, 0, 2, 2, 3, 8, 12, 10, 5, 9, 7, 10, 45, 18,
};
Sorter sorter;
sorter(collection, collection + size);
return helpers::is_sorted(collection, collection + size);
}
}
TEMPLATE_TEST_CASE( "test most adapters in a constexpr context", "[adapters][constexpr]",
cppsort::hybrid_adapter<cppsort::insertion_sorter>,
cppsort::drop_merge_adapter<cppsort::insertion_sorter> )
{
constexpr bool is_sorted = test_constexpr_sorter<TestType>();
STATIC_CHECK( is_sorted );
}