2017-12-29 06:13:28 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <platform.h>
|
|
|
|
#endif
|
2015-01-14 22:33:58 +01:00
|
|
|
#include <CuTest.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "rng.h"
|
|
|
|
|
|
|
|
static void test_rng_round(CuTest * tc)
|
|
|
|
{
|
2018-12-09 03:42:08 +01:00
|
|
|
double f = rng_double();
|
|
|
|
int r = RAND_ROUND(f);
|
|
|
|
CuAssertTrue(tc, f >= 0);
|
|
|
|
CuAssertTrue(tc, r <= (int)f + 1);
|
|
|
|
CuAssertTrue(tc, r >= (int)f);
|
|
|
|
CuAssertTrue(tc, r == (int)r);
|
|
|
|
CuAssertTrue(tc, r == RAND_ROUND(r));
|
2015-01-14 22:33:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CuSuite *get_rng_suite(void)
|
|
|
|
{
|
2015-01-30 22:30:11 +01:00
|
|
|
CuSuite *suite = CuSuiteNew();
|
|
|
|
SUITE_ADD_TEST(suite, test_rng_round);
|
|
|
|
return suite;
|
2015-01-14 22:33:58 +01:00
|
|
|
}
|