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));
}
}
};