Introduce Catch's own RNG based on the PCG family of RNGs

In the future, we will also want to introduce our own
`uniform_int_distribution` and `uniform_real_distribution` to get
repeatable test runs across different platforms.
This commit is contained in:
Martin Hořeňovský
2019-10-07 19:56:23 +02:00
parent 319cb9e1da
commit 535da5c513
14 changed files with 565 additions and 23 deletions
+12
View File
@@ -506,4 +506,16 @@ namespace Catch {
else
CATCH_INTERNAL_ERROR("No result capture instance");
}
void seedRng(IConfig const& config) {
if (config.rngSeed() != 0) {
std::srand(config.rngSeed());
rng().seed(config.rngSeed());
}
}
unsigned int rngSeed() {
return getCurrentContext().getConfig()->rngSeed();
}
}