mitsuba-af602c6fd98a/src/tests/test_random.cpp
// Test that the member function Random::set works as intended
Test that the member function Random::set works as intended
Test that the member function Random :: set works as intended
void TestRandom::test09_set()
{
	const int N = 1000000;
	ref<Random> rnd1 = new Random(1234);
	ref<Random> rnd2 = new Random(5678);
	for (int i = 0; i < N; ++i) {
		const uint64_t v1 = rnd1->nextULong();
		const uint64_t v2 = rnd2->nextULong();
		assertTrue(v1 != v2);
	}
	rnd1->set(rnd2);
	for (int i = 0; i < N; ++i) {
		const uint64_t v1 = rnd1->nextULong();
		const uint64_t v2 = rnd2->nextULong();
		assertTrue(v1 == v2);
	}
	rnd1->seed(rnd2);
	for (int i = 0; i < N; ++i) {
		const uint64_t v1 = rnd1->nextULong();
		const uint64_t v2 = rnd2->nextULong();
		assertTrue(v1 != v2);
	}
}
void TestRandom :: test09_set ( ) { const int N = 1000000 ; ref < Random > rnd1 = new Random ( 1234 ) ; ref < Random > rnd2 = new Random ( 5678 ) ; for ( int i = 0 ; i < N ; ++ i ) { const uint64_t v1 = rnd1 -> nextULong ( ) ; const uint64_t v2 = rnd2 -> nextULong ( ) ; assertTrue ( v1 != v2 ) ; } rnd1 -> set ( rnd2 ) ; for ( int i = 0 ; i < N ; ++ i ) { const uint64_t v1 = rnd1 -> nextULong ( ) ; const uint64_t v2 = rnd2 -> nextULong ( ) ; assertTrue ( v1 == v2 ) ; } rnd1 -> seed ( rnd2 ) ; for ( int i = 0 ; i < N ; ++ i ) { const uint64_t v1 = rnd1 -> nextULong ( ) ; const uint64_t v2 = rnd2 -> nextULong ( ) ; assertTrue ( v1 != v2 ) ; } }
Test that the member function Random::set works as intended
Test that the member function Random :: set works as intended