5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_TESTING_UNIQUE_TEST_VALUE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_TESTING_UNIQUE_TEST_VALUE_HPP_
12#include "arene/base/stdlib_choice/cstddef.hpp"
13#include "arene/base/stdlib_choice/enable_if.hpp"
14#include "arene/base/stdlib_choice/ignore.hpp"
15#include "arene/base/stdlib_choice/terminate.hpp"
20#if ARENE_IS_OFF(ARENE_STDLIB_LIBARENECXX)
25ARENE_IGNORE_ALL(
"-Wfloat-equal",
"exact equality is intended for floating point as we are testing uniqueness");
36template <
class T, std::
size_t N,
class =
void>
37struct assert_test_values_are_unique;
42template <
class T,
class =
void>
43constexpr extern bool is_test_value_noexcept_usable_v =
false;
51constexpr extern bool is_test_value_noexcept_usable_v<
63 constexpr auto operator()() const noexcept ->
void {}
73template <
class T, std::
size_t N>
74constexpr auto are_test_values_unique() noexcept(is_test_value_noexcept_usable_v<T>) ->
bool {
78 assert_test_values_are_unique<T, N - 1U>>;
79 assert_unique_for_smaller_n{}();
83 auto equal_to_any_previous =
false;
86 equal_to_any_previous =
true;
91 return self_equal && !equal_to_any_previous;
101template <
class T, std::
size_t N,
class>
102struct assert_test_values_are_unique
110 auto operator()() const noexcept(is_test_value_noexcept_usable_v<T>) ->
void
112 static auto const unique = [] {
113 if (!are_test_values_unique<T, N>()) {
114#if ARENE_IS_OFF(ARENE_STDLIB_LIBARENECXX)
116 <<
"ERROR: test requested unique values but "
117 <<
"'arene::base::testing::test_values<"
121 <<
" duplicates an earlier test value\n";
139template <
class T, std::
size_t N>
140struct assert_test_values_are_unique<
143 std::
enable_if_t<(std::ignore = (test_value<T>(0U) == test_value<T>(0U)), true)>>
146 static constexpr bool value = are_test_values_unique<T, N>();
154 constexpr auto operator()() const noexcept ->
void
156 static_assert(value,
"test requested N unique values but 'arene::base::testing::test_values' produces duplicates");
178template <
class T, std::
size_t N>
182 "if tests request a unique test value, the test value type must provide an equality operator"
184 detail::assert_test_values_are_unique<T, N>{}();
Provides macros used to disable and enable compiler specific diagnostics using the _Pragma operator.
#define ARENE_IGNORE_END()
Ends a region of a suppressed diagnostic.
Definition diagnostics.hpp:136
#define ARENE_IGNORE_START()
Begins a region of a suppressed diagnostic.
Definition diagnostics.hpp:131
#define ARENE_IGNORE_ALL(s, comment)
Pushes an ignore for a diagnostic into the compiler for any compiler.
Definition diagnostics.hpp:122
constexpr auto test_value(std::size_t idx) noexcept(noexcept(customization_detail::test_value_generator< T >::test_value(idx))) -> T
Get the idx 'th test value of type T.
Definition customization.hpp:108
constexpr auto unique_test_value() noexcept(detail::is_test_value_noexcept_usable_v< T >) ->
obtain the nth unique arene::base::testing::test_value
Definition unique_test_value.hpp:179
typename static_if< B >::template then_else< T, F > conditional_t
lazily select between two types based on a boolean condition
Definition conditional.hpp:28
constexpr auto type_name_v
The name of a type as an inline_string.
constexpr bool is_equality_comparable_v
Definition accumulate.hpp:36
auto unique(I first, I last, P pred) noexcept(//std::is_nothrow_copy_constructible_v< I > &&//noexcept(std::declval< I & >()==std::declval< I & >()) &&//noexcept(std::declval< I & >() !=std::declval< I & >()) &&//noexcept(++std::declval< I & >()) &&//noexcept(!std::declval< P & >()(*std::declval< I & >(), *std::declval< I & >())) &&//std::is_nothrow_assignable_v<//arene::base::algorithm_detail::iter_reference_t< I >,//std::remove_reference_t< arene::base::algorithm_detail::iter_reference_t< I > > && >//) -> I
removes consecutive elements in a range
Definition unique.hpp:79
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
void terminate() noexcept
function called when exception handling fails
Definition terminate.cpp:26
static constexpr auto const & ignore
An object to which anything can be assigned, which ignores the assigned value.
Definition ignore.hpp:72