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

summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-10-22 17:04:08 +0200
committerMartin Hořeňovský2022-10-22 22:18:30 +0200
commitf1361ef6243ec88038a6b4f013c405f2df3df376 (patch)
tree913fa278cdc2d68dd4527468e2b6f0931dc205e5 /tests
parentd1e7544e9f8b233af8ffd37df9bee12492215aff (diff)
downloadcatch3-f1361ef6243ec88038a6b4f013c405f2df3df376.tar.gz
Refactor how the RNG seed is parsed when handling cmdline
Diffstat (limited to 'tests')
-rw-r--r--tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp
index e7b0c9c1..cbb0a988 100644
--- a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp
@@ -737,3 +737,31 @@ TEST_CASE("Win32 colour implementation is compile-time optional",
REQUIRE_FALSE( result );
#endif
}
+
+TEST_CASE( "Parse rng seed in different formats", "[approvals][cli][rng-seed]" ) {
+ Catch::ConfigData config;
+ auto cli = Catch::makeCommandLineParser( config );
+
+ SECTION("well formed cases") {
+ char const* seed_string;
+ uint32_t seed_value;
+ // GCC-5 workaround
+ using gen_type = std::tuple<char const*, uint32_t>;
+ std::tie( seed_string, seed_value ) = GENERATE( table<char const*, uint32_t>({
+ gen_type{ "0xBEEF", 0xBEEF },
+ gen_type{ "12345678", 12345678 }
+ } ) );
+ CAPTURE( seed_string );
+
+ auto result = cli.parse( { "tests", "--rng-seed", seed_string } );
+
+ REQUIRE( result );
+ REQUIRE( config.rngSeed == seed_value );
+ }
+ SECTION( "Error cases" ) {
+ auto seed_string =
+ GENERATE( "0xSEED", "999999999999", "08888", "BEEF", "123 456" );
+ CAPTURE( seed_string );
+ REQUIRE_FALSE( cli.parse( { "tests", "--rng-seed", seed_string } ) );
+ }
+}