5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_TESTING_CUSTOMIZATION_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_INLINE_CONTAINER_TESTING_CUSTOMIZATION_HPP_
12#include "arene/base/detail/iterator_interface.hpp"
13#include "arene/base/stdlib_choice/cstddef.hpp"
14#include "arene/base/stdlib_choice/enable_if.hpp"
15#include "arene/base/stdlib_choice/initializer_list.hpp"
16#include "arene/base/stdlib_choice/integral_constant.hpp"
17#include "arene/base/stdlib_choice/is_copy_constructible.hpp"
18#include "arene/base/stdlib_choice/is_floating_point.hpp"
19#include "arene/base/stdlib_choice/is_integral.hpp"
20#include "arene/base/stdlib_choice/is_move_assignable.hpp"
21#include "arene/base/stdlib_choice/is_move_constructible.hpp"
22#include "arene/base/stdlib_choice/is_signed.hpp"
23#include "arene/base/stdlib_choice/is_unsigned.hpp"
24#include "arene/base/stdlib_choice/iterator_tags.hpp"
25#include "arene/base/stdlib_choice/make_signed.hpp"
26#include "arene/base/stdlib_choice/move.hpp"
27#include "testlibs/utilities/configurable_value.hpp"
40template <
typename T,
typename = ::arene::base::constra
ints<>>
50 to_array_of<T>({0U, 8U, 19U, 6612U, 777124U, 7U, 609124U, 1224545862U, 2561U, 976173U});
59 to_array_of<T>({1, -2, 6, -24, 120, -720, 5'040, -40'320, 362'880, -3'628'800});
68namespace customization_detail {
72struct test_value_generator {
78 "To use a type T for parameterized testing, you must specialize arene::base::testing::test_value_array<T> for "
79 "copyable types or arene::base::testing::test_value<T> for non-copyable types"
90template <
typename T, ::testing::throws_on ThrowsOn, ::testing::disable Disable, ::testing::is_constexpr IsConstexpr>
91struct test_value_generator<::testing::configurable_value<T, ThrowsOn, Disable, IsConstexpr>> {
95 )
noexcept((ThrowsOn & ::testing::throws_on::value_construct) == ::testing::throws_on::nothing) -> T {
96 return {test_value_generator<T>::test_value(idx)};
109)
noexcept(
noexcept(customization_detail::test_value_generator<T>::test_value(idx))) -> T {
110 return customization_detail::test_value_generator<T>::test_value(idx);
115template <
typename T,
typename = std::
integral_constant<
bool, true>>
124namespace customization_detail {
130template <
typename T,
bool IsConstexpr,
std::size_t... Indices>
131class init_list_holder {
142template <
typename T,
bool IsConstexpr,
std::size_t... Indices>
150class init_list_holder<T, false, Indices...> {
168extern constexpr customization_detail::init_list_holder<T, has_constexpr_test_value<T>, Indices...>
176 static constexpr bool test_value_is_noexcept =
noexcept(
test_value<T>(0));
179 using iterator_interface = detail::iterator_interface<rvalue_iterator<T>>;
197 : iterator_interface(),
198 current_index_(index),
199 current_value_(get_test_value(current_index_)) {}
204 : iterator_interface(),
205 current_index_(other.current_index_),
206 current_value_(get_test_value(current_index_)) {}
212 : iterator_interface(),
213 current_index_(other.current_index_),
214 current_value_(
std::
move(other.current_value_)) {}
219 current_index_ = other.current_index_;
220 current_value_ = get_test_value(current_index_);
228 current_index_ = other.current_index_;
229 current_value_ =
std::move(other.current_value_);
244 current_index_ += diff;
245 current_value_ = get_test_value(current_index_);
255 return left.current_index_ - right.current_index_;
268 static constexpr auto get_test_value(
difference_type index)
noexcept(test_value_is_noexcept) -> T {
constexpr auto operator+=(difference_type diff) noexcept(test_value_is_noexcept) -> rvalue_iterator &
Shift an rvalue_iterator by the given amount.
Definition customization.hpp:243
T && reference
The reference type of the iterator; a value of the expected type, since there's nothing to rvalue-ref...
Definition customization.hpp:187
std::random_access_iterator_tag iterator_category
The iterator category; random access because we just store an index and yield from it.
Definition customization.hpp:191
constexpr auto operator=(rvalue_iterator const &other) noexcept(test_value_is_noexcept) -> rvalue_iterator &
Copy assign an rvalue_iterator, retrieving a new test value so that the value type can be move-only.
Definition customization.hpp:218
friend constexpr auto operator-(rvalue_iterator const &left, rvalue_iterator const &right) noexcept -> difference_type
Get the difference between two rvalue_iterators.
Definition customization.hpp:253
~rvalue_iterator()=default
Destroy an rvalue_iterator.
T * pointer
The pointer type of the iterator; basically not meaningful, and it would be ill-formed to use it.
Definition customization.hpp:185
std::make_signed_t< std::size_t > difference_type
The difference type of the iterator; test_value takes std::size_t so the difference is that but signe...
Definition customization.hpp:189
constexpr auto operator*() noexcept -> reference
Dereference an rvalue_iterator; data may no longer be meaningful after the first use.
Definition customization.hpp:237
T value_type
The value type of the iterator; this is the type whose test values are being retrieved.
Definition customization.hpp:183
constexpr rvalue_iterator(rvalue_iterator &&other) noexcept(std::is_nothrow_move_constructible< T >::value)
Move construct an rvalue_iterator.
Definition customization.hpp:211
constexpr rvalue_iterator(rvalue_iterator const &other) noexcept(test_value_is_noexcept)
Copy construct an rvalue_iterator, retrieving a new test value so that the value type can be move-onl...
Definition customization.hpp:203
constexpr auto operator=(rvalue_iterator &&other) noexcept(std::is_nothrow_move_assignable< T >::value) -> rvalue_iterator &
Move assign an rvalue_iterator.
Definition customization.hpp:226
constexpr rvalue_iterator(difference_type index=0) noexcept(test_value_is_noexcept)
Construct an rvalue_iterator containing the test value with the given index (defaulting to 0)
Definition customization.hpp:196
Implementation of std::initializer_list for brace initialization.
Definition initializer_list.hpp:21
static constexpr value_type value
Definition integral_constant.hpp:34
An empty tag type corresponding to a random access iterator.
Definition iterator_tags.hpp:29
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
Definition customization.hpp:31
constexpr bool has_constexpr_test_value
Check whether or not a given type's test_value function works in constexpr contexts.
Definition customization.hpp:116
constexpr customization_detail::init_list_holder< T, has_constexpr_test_value< T >, Indices... > test_initializer_list
A function object returning a std::initializer_list of one test_value per index in the given pack.
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 ::arene::base::array< T, 0UL > test_value_array
An array used in the default implementation of test_value ; by default it's empty and unusable.
Definition accumulate.hpp:37
constexpr auto move(InIterator first, InIterator last, OutIterator output) noexcept(noexcept(*first++) &&noexcept(output++) &&//CODEQLFP(EXP52-CPP) CODEQLFP(A5-2-6) noexcept(first !=last) &&//CODEQLFP(A5-2-6) std::is_nothrow_assignable<, typename std::iterator_traits< InIterator >::value_type >::value) -> OutIterator
Moves the elements in the range [first, last), to another range beginning at output,...
Definition move.hpp:46
constexpr auto to_array_of
construct an array with a desired element type from a C-array.
Definition to_array.hpp:134
Definition accumulate.hpp:36
typename make_signed< Type >::type make_signed_t
A type alias for the equivalent signed type for integral and enumeration types other than bool.
Definition make_signed.hpp:252
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
::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