TTS v3.0.0
The Tiny Test System
 
Loading...
Searching...
No Matches
tts::randoms< Mx, Mn > Struct Template Reference

Random generator between two bounds using realistic_distribution. More...

Detailed Description

template<typename Mx, typename Mn>
struct tts::randoms< Mx, Mn >

Random generator between two bounds using realistic_distribution.

This generator produces random values between two bounds (inclusive) using a realistic distribution. The realistic distribution aims to provide a more uniform coverage of the range by avoiding too many extreme values.

Template Parameters
MxType of the upper bound
MnType of the lower bound

Example

#define TTS_MAIN // No need for main()
#include <tts/tts.hpp>
#include <array>
TTS_CASE_WITH("Test tts::randoms generator",
(std::array<float, 10>, std::array<int, 7>, double),
tts::randoms {-4, 4})<typename T>(T const& args)
{
if constexpr(std::is_arithmetic_v<T>)
{
TTS_GREATER_EQUAL(args, static_cast<T>(-4));
TTS_LESS_EQUAL(args, static_cast<T>(4));
}
else
{
using value_type = typename T::value_type;
for(std::size_t i = 0; i < args.size(); ++i)
{
TTS_GREATER_EQUAL(args[ i ], static_cast<value_type>(-4));
TTS_LESS_EQUAL(args[ i ], static_cast<value_type>(4));
}
}
};
#define TTS_LESS_EQUAL(LHS, RHS,...)
Performs less-or-equal-than comparison between two expressions.
Definition relation.hpp:218
#define TTS_GREATER_EQUAL(LHS, RHS,...)
Performs greater-or-equal-than comparison between two expressions.
Definition relation.hpp:239
#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
Random generator between two bounds using realistic_distribution.
Definition generator.hpp:281