TTS v3.0.0
The Tiny Test System
 
Loading...
Searching...
No Matches
tts::between< T, U > Struct Template Reference

Defines a data generator that produce values between two bounds. More...

Detailed Description

template<typename T, typename U = T>
struct tts::between< T, U >

Defines a data generator that produce values between two bounds.

This generator produces values linearly spaced between two bounds (inclusive). For a size N, the produced values are: first, first+step, first+2*step, ..., last, where step = (last-first)/(N-1).

When generated values exceed the last bound due to rounding, the last bound is returned instead.

Template Parameters
TType of the first bound
UType of the last bound

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <array>
TTS_CASE_WITH("Test tts::between generator",
(std::array<float, 10>, int, double),
tts::between {-4, 4})<typename T>(T const& args)
{
if constexpr(std::is_arithmetic_v<T>) { TTS_EQUAL(args, static_cast<T>(-4)); }
else
{
using value_type = typename T::value_type;
for(std::size_t i = 0; i < args.size(); ++i)
{
args[ i ],
static_cast<value_type>(-4 + i * 8 / static_cast<value_type>((args.size() - 1))),
4);
}
}
};
#define TTS_ULP_EQUAL(L, R, N,...)
Checks if two values are within a given ULP distance.
Definition precision.hpp:123
#define TTS_EQUAL(LHS, RHS,...)
Performs equality comparison between two expressions.
Definition relation.hpp:134
#define TTS_CASE_WITH(ID, TYPES,...)
Introduces a template test case providing dynamically generated data to the test code.
Definition case.hpp:201
auto constexpr typename_
Evaluates to an object containing the name of the type T in readable form.
Definition typename.hpp:126
Defines a data generator that produce values between two bounds.
Definition generator.hpp:244