mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-21 21:06:11 +01:00
Ensure we always read 32 bit seed from std::random_device
This commit is contained in:
parent
a6f22c5169
commit
b7d70ddcd6
@ -355,8 +355,6 @@ namespace Catch {
|
||||
unsigned int n_resamples,
|
||||
double* first,
|
||||
double* last) {
|
||||
auto n = static_cast<int>(last - first); // seriously, one can't use integral types without hell in C++
|
||||
|
||||
auto mean = &Detail::mean;
|
||||
auto stddev = &standard_deviation;
|
||||
|
||||
@ -389,6 +387,7 @@ namespace Catch {
|
||||
auto stddev_estimate = Estimate(stddev);
|
||||
#endif // CATCH_USE_ASYNC
|
||||
|
||||
auto n = static_cast<int>(last - first); // seriously, one can't use integral types without hell in C++
|
||||
double outlier_variance = Detail::outlier_variance(mean_estimate, stddev_estimate, n);
|
||||
|
||||
return { mean_estimate, stddev_estimate, outlier_variance };
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <catch2/internal/catch_random_seed_generation.hpp>
|
||||
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_random_integer_helpers.hpp>
|
||||
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
@ -21,10 +22,10 @@ namespace Catch {
|
||||
return static_cast<std::uint32_t>( std::time( nullptr ) );
|
||||
|
||||
case GenerateFrom::Default:
|
||||
case GenerateFrom::RandomDevice:
|
||||
// In theory, a platform could have random_device that returns just
|
||||
// 16 bits. That is still some randomness, so we don't care too much
|
||||
return static_cast<std::uint32_t>( std::random_device{}() );
|
||||
case GenerateFrom::RandomDevice: {
|
||||
std::random_device rd;
|
||||
return Detail::fillBitsFrom<std::uint32_t>( rd );
|
||||
}
|
||||
|
||||
default:
|
||||
CATCH_ERROR("Unknown generation method");
|
||||
|
Loading…
Reference in New Issue
Block a user