Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_run_context.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2019-10-06 21:47:54 +0200
committerMartin Hořeňovský2019-10-07 19:56:23 +0200
commit535da5c5132bcbba6f29c60ed6bb7ded29b9ec3e (patch)
tree2cf1263bd8d3707e1f4087885dbdf7fa5a7ed84c /include/internal/catch_run_context.cpp
parent319cb9e1daec5076ff1a3acd10b959c2bce05c5b (diff)
downloadcatch3-535da5c5132bcbba6f29c60ed6bb7ded29b9ec3e.tar.gz
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.
Diffstat (limited to 'include/internal/catch_run_context.cpp')
-rw-r--r--include/internal/catch_run_context.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp
index 79f906d6..2eb84fb9 100644
--- a/include/internal/catch_run_context.cpp
+++ b/include/internal/catch_run_context.cpp
@@ -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();
+ }
+
}