]> git.localhorst.tv Git - blank.git/commitdiff
fix rng stability test
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 9 Nov 2016 16:46:08 +0000 (17:46 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 9 Nov 2016 16:46:08 +0000 (17:46 +0100)
also check 0 special case

tst/rand/StabilityTest.cpp

index 9ed047d211e931de1cd32adeeb897026e07cf509..928cdd6a464f428bda83d503fd3c7edf345ed09f 100644 (file)
@@ -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
        );
 }