libcruft-util/test/random.cpp

34 lines
744 B
C++
Raw Permalink Normal View History

#include <cruft/util/tap.hpp>
#include <cruft/util/random.hpp>
#include <iostream>
///////////////////////////////////////////////////////////////////////////////
int
main ()
{
cruft::TAP::logger tap;
{
constexpr int ITERATIONS = 2048;
constexpr int HI = 13;
constexpr int LO = 3;
bool success = true;
for (int i = 0; i < ITERATIONS; ++i) {
auto const val = cruft::random::uniform<int> (LO, HI);
if (val < LO || val > HI) {
std::cerr << val << '\n';
success = false;
break;
}
}
tap.expect (success, "default uniform random int is within correct range");
}
return tap.status ();
}