mirror of
https://github.com/catchorg/Catch2
synced 2026-02-25 17:02:21 +00:00
Add validation for --benchmark-samples to prevent crash with zero value (#3056)
* Add validation for --benchmark-samples to prevent crash with zero samples * Add automated test for benchmark samples validation * Update baselines for benchmark-samples validation * Add missing test for benchmark samples validation --------- Co-authored-by: Chan Aung <chan@Thinkpad.localdomain>
This commit is contained in:
@@ -301,6 +301,23 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
||||
|
||||
REQUIRE(config.benchmarkSamples == 200);
|
||||
}
|
||||
SECTION("samples must be greater than zero"){
|
||||
auto result = cli.parse({"test", "--benchmark-samples=0"});
|
||||
|
||||
CHECK_FALSE(result);
|
||||
REQUIRE_THAT(
|
||||
result.errorMessage(),
|
||||
ContainsSubstring("Benchmark samples must be greater than 0"));
|
||||
}
|
||||
|
||||
SECTION("samples must be parseable") {
|
||||
auto result = cli.parse({"test", "--benchmark-samples=abc"});
|
||||
|
||||
CHECK_FALSE(result);
|
||||
REQUIRE_THAT(
|
||||
result.errorMessage(),
|
||||
ContainsSubstring("Could not parse 'abc' as benchmark samples"));
|
||||
}
|
||||
|
||||
SECTION("resamples") {
|
||||
CHECK(cli.parse({ "test", "--benchmark-resamples=20000" }));
|
||||
|
||||
Reference in New Issue
Block a user