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

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-10-26 23:26:07 +0200
committerMartin Hořeňovský2021-10-27 17:24:30 +0200
commit5ac1ffe9ee394ca6b8ffeee0bd969170c817629e (patch)
tree3b595257380e5957c63fdf59b7a2068c651dd4c7 /tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp
parent3087e19cc72ccb6caddc42ec2f39eebc56160754 (diff)
downloadcatch3-5ac1ffe9ee394ca6b8ffeee0bd969170c817629e.tar.gz
Improve shardIndex/Count cli argument parsing
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp')
-rw-r--r--tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp54
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]") {