2022-02-11 15:26:10 +01:00
|
|
|
#include "Catch2.h"
|
2021-11-15 11:32:27 +01:00
|
|
|
#include "../_TestingUtilities/Testutil.h"
|
2022-02-11 15:26:10 +01:00
|
|
|
#include <Eule/Random.h>
|
2021-11-15 11:32:27 +01:00
|
|
|
#include <array>
|
|
|
|
|
2022-03-06 20:05:34 +01:00
|
|
|
using namespace Leonetienne::Eule;
|
2021-11-15 11:32:27 +01:00
|
|
|
|
2022-02-11 15:26:10 +01:00
|
|
|
// Checks that the produced unsigned-integer distribution shows a big standard deviation
|
|
|
|
TEST_CASE(__FILE__"/Uint_Big_Standard_Deviation", "[Random][RandomInt]")
|
2021-11-15 11:32:27 +01:00
|
|
|
{
|
2022-02-11 15:26:10 +01:00
|
|
|
// Setup
|
|
|
|
std::vector<unsigned int> rands;
|
|
|
|
rands.resize(1000);
|
|
|
|
|
|
|
|
// Exercise
|
|
|
|
// Create 1000 random values
|
|
|
|
std::generate_n(rands.data(), rands.size(), []()->unsigned int { return Random::RandomUint(); });
|
|
|
|
|
|
|
|
// Verify
|
|
|
|
const double stddev = Testutil::Stddev<unsigned int>(rands);
|
|
|
|
REQUIRE(stddev >= 1000000);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checks that the produced integer distribution shows a big standard deviation
|
|
|
|
TEST_CASE(__FILE__"/Int_Big_Standard_Deviation", "[Random][RandomInt]")
|
|
|
|
{
|
|
|
|
// Setup
|
|
|
|
std::vector<int> rands;
|
|
|
|
rands.resize(1000);
|
|
|
|
|
|
|
|
// Exercise
|
|
|
|
// Create 1000 random values
|
|
|
|
std::generate_n(rands.data(), rands.size(), []()->int { return Random::RandomInt(); });
|
|
|
|
|
|
|
|
// Verify
|
|
|
|
const double stddev = Testutil::Stddev<int>(rands);
|
|
|
|
REQUIRE(stddev >= 1000000);
|
|
|
|
|
|
|
|
return;
|
2021-11-15 11:32:27 +01:00
|
|
|
}
|