mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Add generateRandomSeed utility to generate randomness seed
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/internal/catch_random_number_generator.hpp>
|
||||
#include <catch2/internal/catch_random_seed_generation.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
TEST_CASE("Our PCG implementation provides expected results for known seeds", "[rng]") {
|
||||
Catch::SimplePcg32 rng;
|
||||
@@ -40,3 +42,18 @@ TEST_CASE("Comparison ops", "[rng]") {
|
||||
REQUIRE_FALSE(SimplePcg32{ 1 } == SimplePcg32{ 2 });
|
||||
REQUIRE_FALSE(SimplePcg32{ 1 } != SimplePcg32{ 1 });
|
||||
}
|
||||
|
||||
TEST_CASE("Random seed generation reports unknown methods", "[rng][seed]") {
|
||||
REQUIRE_THROWS(Catch::generateRandomSeed(static_cast<Catch::GenerateFrom>(77)));
|
||||
}
|
||||
|
||||
TEST_CASE("Random seed generation accepts known methods", "[rng][seed]") {
|
||||
using Catch::GenerateFrom;
|
||||
const auto method = GENERATE(
|
||||
GenerateFrom::Time,
|
||||
GenerateFrom::RandomDevice,
|
||||
GenerateFrom::Default
|
||||
);
|
||||
|
||||
REQUIRE_NOTHROW(Catch::generateRandomSeed(method));
|
||||
}
|
||||
|
Reference in New Issue
Block a user