mitsuba-af602c6fd98a/src/tests/test_random.cpp
/* Check that the returned values are within range */
Check that the returned values are within range
Check that the returned values are within range
void TestRandom::test02_range()
{
	const int N = 1000;
	ref<Random> rnd = new Random;
	for (int i = 0; i < N*N; ++i) {
		test02_helper<Float>(rnd);
		test02_helper<uint32_t>(rnd);
		test02_helper<uint64_t>(rnd);
	}
	std::srand(0x695dff6c);
	for (int k = 0; k < N; ++k) {
		const unsigned int max = static_cast<unsigned int>(std::rand()) + 1;
		for (int i = 0; i < N; ++i) {
			const uint32_t v1 = rnd->nextUInt(max);
			assertTrue(v1 < max);
			const size_t v2   = rnd->nextSize(max);
			assertTrue(v2 < max);
		}
	}
}
void TestRandom :: test02_range ( ) { const int N = 1000 ; ref < Random > rnd = new Random ; for ( int i = 0 ; i < N * N ; ++ i ) { test02_helper < Float > ( rnd ) ; test02_helper < uint32_t > ( rnd ) ; test02_helper < uint64_t > ( rnd ) ; } std :: srand ( 0x695dff6c ) ; for ( int k = 0 ; k < N ; ++ k ) { const unsigned int max = static_cast < unsigned int > ( std :: rand ( ) ) + 1 ; for ( int i = 0 ; i < N ; ++ i ) { const uint32_t v1 = rnd -> nextUInt ( max ) ; assertTrue ( v1 < max ) ; const size_t v2 = rnd -> nextSize ( max ) ; assertTrue ( v2 < max ) ; } } }
Check that the returned values are within range
Check that the returned values are within range