2
0
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:
qerased
2026-01-03 01:15:13 +03:00
committed by GitHub
parent b7e31c9ab3
commit b66b89374e
15 changed files with 238 additions and 12 deletions

View File

@@ -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" }));