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

Defines a data generator that produce a ramp of data. More...

Detailed Description

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

Defines a data generator that produce a ramp of data.

This generator produces a ramp starting from an initial value and increasing by a fixed step at each call. I.e., for a size N, the produced values are: start, start+step, start+2*step, ..., start+(N-1)*step.

Template Parameters
TType of the initial value
UType of the step value

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <array>
TTS_CASE_WITH("Test tts::ramp generator",
(std::array<float, 10>, int, double),
tts::ramp {65},
tts::ramp {1, 2})<typename T>(T const& ramp1, T const& ramp2)
{
if constexpr(std::is_arithmetic_v<T>)
{
TTS_EQUAL(ramp1, static_cast<T>(65));
TTS_EQUAL(ramp2, static_cast<T>(1));
}
else
{
for(std::size_t i = 0; i < ramp1.size(); ++i)
{
TTS_EQUAL(ramp1[ i ], static_cast<typename T::value_type>(65 + i));
}
for(std::size_t i = 0; i < ramp2.size(); ++i)
{
TTS_EQUAL(ramp2[ i ], static_cast<typename T::value_type>(1 + i * 2));
}
}
};
#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 a ramp of data.
Definition generator.hpp:164