diff options
| author | Martin Hořeňovský | 2021-10-26 23:26:07 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-10-27 17:24:30 +0200 |
| commit | 5ac1ffe9ee394ca6b8ffeee0bd969170c817629e (patch) | |
| tree | 3b595257380e5957c63fdf59b7a2068c651dd4c7 /tests/SelfTest/IntrospectiveTests | |
| parent | 3087e19cc72ccb6caddc42ec2f39eebc56160754 (diff) | |
| download | catch3-5ac1ffe9ee394ca6b8ffeee0bd969170c817629e.tar.gz | |
Improve shardIndex/Count cli argument parsing
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests')
| -rw-r--r-- | tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp index 5b58bdec..332cbe50 100644 --- a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp @@ -569,27 +569,53 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" REQUIRE(config.benchmarkWarmupTime == 10); } } +} - SECTION("Sharding options") { - SECTION("shard-count") { - CHECK(cli.parse({ "test", "--shard-count=8"})); +TEST_CASE("Parsing sharding-related cli flags", "[sharding]") { + using namespace Catch::Matchers; - REQUIRE(config.shardCount == 8); - } + Catch::ConfigData config; + auto cli = Catch::makeCommandLineParser(config); - SECTION("shard-index") { - CHECK(cli.parse({ "test", "--shard-index=2"})); + SECTION("shard-count") { + CHECK(cli.parse({ "test", "--shard-count=8" })); - REQUIRE(config.shardIndex == 2); - } + REQUIRE(config.shardCount == 8); + } - SECTION("Zero shard-count") { - auto result = cli.parse({ "test", "--shard-count=0"}); + SECTION("Negative shard count reports error") { + auto result = cli.parse({ "test", "--shard-count=-1" }); - CHECK( !result ); - CHECK_THAT( result.errorMessage(), ContainsSubstring( "The shard count must be greater than 0" ) ); - } + CHECK_FALSE(result); + REQUIRE_THAT(result.errorMessage(), ContainsSubstring("Shard count must be a positive number")); + } + + SECTION("Zero shard count reports error") { + auto result = cli.parse({ "test", "--shard-count=0" }); + + CHECK_FALSE(result); + REQUIRE_THAT(result.errorMessage(), ContainsSubstring("Shard count must be a positive number")); + } + + SECTION("shard-index") { + CHECK(cli.parse({ "test", "--shard-index=2" })); + + REQUIRE(config.shardIndex == 2); } + + SECTION("Negative shard index reports error") { + auto result = cli.parse({ "test", "--shard-index=-12" }); + + CHECK_FALSE(result); + REQUIRE_THAT(result.errorMessage(), ContainsSubstring("Shard index must be a non-negative number")); + } + + SECTION("Shard index 0 is accepted") { + CHECK(cli.parse({ "test", "--shard-index=0" })); + + REQUIRE(config.shardIndex == 0); + } + } TEST_CASE("Test with special, characters \"in name", "[cli][regression]") { |