diff --git a/CMakeLists.txt b/CMakeLists.txt index a6600f9e..cdfa1058 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -568,6 +568,7 @@ if (TESTS) preprocessor quaternion rand/buckets + random range rational region diff --git a/test/random.cpp b/test/random.cpp new file mode 100644 index 00000000..a8c17195 --- /dev/null +++ b/test/random.cpp @@ -0,0 +1,34 @@ +#include "tap.hpp" + +#include "random.hpp" + +#include + + +/////////////////////////////////////////////////////////////////////////////// +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 (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 (); +} \ No newline at end of file