c88746d2da
I move all of the core tests into the core/ directory to keep them together. Gui unit tests will be put in new directories. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
37 lines
661 B
C++
37 lines
661 B
C++
/*
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
|
|
#include <core/random.h>
|
|
#include <tests/test.h>
|
|
|
|
#include <sstream>
|
|
|
|
static void do_test_rng(unsigned int seed)
|
|
{
|
|
random_seed(seed);
|
|
|
|
for (unsigned int i = 0; i <= 10; i++) {
|
|
if (i <= seed)
|
|
test_equal(random(seed, i), seed);
|
|
else
|
|
test_equal(random(seed, i), seed + (i % (i - seed)));
|
|
}
|
|
}
|
|
|
|
static void test_rng(unsigned int seed)
|
|
{
|
|
std::stringstream ss;
|
|
ss << " (seed = " << seed << ")";
|
|
std::string seed_str = ss.str();
|
|
|
|
run_test("Random Number Generator Test" + seed_str, do_test_rng, seed);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
for (unsigned int i = 0; i < 10; i++)
|
|
test_rng(i);
|
|
return 0;
|
|
}
|