tests: delete goodness-of-fit tests from Util/TestRandom
They're not implemented correctly and fail too frequently.
Change-Id: Ibb228ba3193cd4491b330e22f5d6d8502adf8d3c
diff --git a/tests/unit/util/random.t.cpp b/tests/unit/util/random.t.cpp
index 1aeca1a..c81c09e 100644
--- a/tests/unit/util/random.t.cpp
+++ b/tests/unit/util/random.t.cpp
@@ -25,18 +25,15 @@
#include "tests/boost-test.hpp"
#include <array>
-#include <cmath>
#include <thread>
-#include <boost/mpl/vector.hpp>
-
namespace ndn {
namespace tests {
BOOST_AUTO_TEST_SUITE(Util)
BOOST_AUTO_TEST_SUITE(TestRandom)
-BOOST_AUTO_TEST_CASE(ThreadLocalRng)
+BOOST_AUTO_TEST_CASE(ThreadLocalEngine)
{
random::RandomNumberEngine* r1 = &random::getRandomNumberEngine();
random::RandomNumberEngine* r2 = nullptr;
@@ -49,105 +46,6 @@
BOOST_CHECK_EQUAL(r1, r3);
}
-class PseudoRandomWord32
-{
-public:
- static uint32_t
- generate()
- {
- return random::generateWord32();
- }
-};
-
-class PseudoRandomWord64
-{
-public:
- static uint64_t
- generate()
- {
- return random::generateWord64();
- }
-};
-
-class SecureRandomWord32
-{
-public:
- static uint32_t
- generate()
- {
- return random::generateSecureWord32();
- }
-};
-
-class SecureRandomWord64
-{
-public:
- static uint64_t
- generate()
- {
- return random::generateSecureWord64();
- }
-};
-
-using RandomGenerators = boost::mpl::vector<PseudoRandomWord32,
- PseudoRandomWord64,
- SecureRandomWord32,
- SecureRandomWord64>;
-
-static double
-getDeviation(const std::vector<uint32_t>& counts, size_t size)
-{
- // Kolmogorov-Smirnov Goodness-of-Fit Test
- // http://www.itl.nist.gov/div898/handbook/eda/section3/eda35g.htm
-
- std::vector<double> edf(counts.size(), 0.0);
- double probability = 0.0;
- for (size_t i = 0; i < counts.size(); i++) {
- probability += 1.0 * counts[i] / size;
- edf[i] = probability;
- }
-
- double t = 0.0;
- for (size_t i = 0; i < counts.size(); i++) {
- t = std::max(t, std::abs(edf[i] - (i * 1.0 / counts.size())));
- }
-
- return t;
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(GoodnessOfFit, RandomGenerator, RandomGenerators)
-{
- const size_t MAX_BINS = 32;
- const uint32_t MAX_ITERATIONS = 35;
-
- std::vector<uint32_t> counts(MAX_BINS, 0);
- for (uint32_t i = 0; i < MAX_ITERATIONS; i++) {
- counts[RandomGenerator::generate() % MAX_BINS]++;
- }
-
- // Check if it is uniform distribution with confidence 0.95
- // http://dlc.erieri.com/onlinetextbook/index.cfm?fuseaction=textbook.appendix&FileName=Table7
- BOOST_CHECK_LE(getDeviation(counts, MAX_ITERATIONS), 0.230);
-}
-
-BOOST_AUTO_TEST_CASE(GenerateSecureBytes)
-{
- // Kolmogorov-Smirnov Goodness-of-Fit Test
- // http://www.itl.nist.gov/div898/handbook/eda/section3/eda35g.htm
-
- std::array<uint8_t, 1024> buf;
- random::generateSecureBytes(buf.data(), buf.size());
-
- std::vector<uint32_t> counts(256, 0);
- for (size_t i = 0; i < buf.size(); i++) {
- counts[buf[i]]++;
- }
-
- // Check if it is uniform distribution with confidence 0.95
- // http://dlc.erieri.com/onlinetextbook/index.cfm?fuseaction=textbook.appendix&FileName=Table7
- BOOST_CHECK_LE(getDeviation(counts, buf.size()), 0.230);
-}
-
// This fixture uses OpenSSL routines to set a dummy random generator that always fails
class FailRandMethodFixture
{