From: Daniel Karbach Date: Wed, 9 Nov 2016 16:46:08 +0000 (+0100) Subject: fix rng stability test X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=f9a060d3e46fbfb0daefc0623fa217a62e5c8c2b;p=blank.git fix rng stability test also check 0 special case --- diff --git a/tst/rand/StabilityTest.cpp b/tst/rand/StabilityTest.cpp index 9ed047d..928cdd6 100644 --- a/tst/rand/StabilityTest.cpp +++ b/tst/rand/StabilityTest.cpp @@ -68,6 +68,7 @@ void StabilityTest::testRNG() { "unexpected value #8 from RNG", uint16_t(0x0000), value ); + random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #9 from RNG", uint16_t(0x0000), value @@ -80,12 +81,12 @@ void StabilityTest::testRNG() { random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #11 from RNG", - uint16_t(0x0000), value + uint16_t(0x2E70), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #12 from RNG", - uint16_t(0x2E70), value + uint16_t(0x0000), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( @@ -100,12 +101,12 @@ void StabilityTest::testRNG() { random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #15 from RNG", - uint16_t(0x0000), value + uint16_t(0x1011), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #16 from RNG", - uint16_t(0x1011), value + uint16_t(0x0000), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( @@ -115,17 +116,17 @@ void StabilityTest::testRNG() { random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #18 from RNG", - uint16_t(0x0000), value + uint16_t(0xB000), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #19 from RNG", - uint16_t(0xB000), value + uint16_t(0x0B0B), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #20 from RNG", - uint16_t(0x0B0B), value + uint16_t(0x0000), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( @@ -135,17 +136,17 @@ void StabilityTest::testRNG() { random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #22 from RNG", - uint16_t(0x0000), value + uint16_t(0x1500), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #23 from RNG", - uint16_t(0x1500), value + uint16_t(0x0454), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #24 from RNG", - uint16_t(0x0454), value + uint16_t(0x0000), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( @@ -155,17 +156,17 @@ void StabilityTest::testRNG() { random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #26 from RNG", - uint16_t(0x0000), value + uint16_t(0xC970), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #27 from RNG", - uint16_t(0xC970), value + uint16_t(0x02E5), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #28 from RNG", - uint16_t(0x02E5), value + uint16_t(0x0000), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( @@ -175,17 +176,27 @@ void StabilityTest::testRNG() { random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #30 from RNG", - uint16_t(0x0000), value + uint16_t(0x0101), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #31 from RNG", - uint16_t(0x0101), value + uint16_t(0x0100), value ); random(value); CPPUNIT_ASSERT_EQUAL_MESSAGE( "unexpected value #32 from RNG", - uint16_t(0x0100), value + uint16_t(0x0000), value + ); + + GaloisLFSR random1(1); + uint16_t value1; + for (int i = 0; i < 32; ++i) { + random1(value1); + } + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "RNG with seeds 0 and 1 differ", + value, value1 ); }