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

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-08-21 00:06:31 +0200
committerMartin Hořeňovský2021-08-21 00:06:31 +0200
commit1cbbc5d2cbac7f497fa5e2128f6779ee2e5fb510 (patch)
tree80e0013f75d9526e1d173f50a87681a2d1ba067d
parent7f3297f7e81c4d96329f56e13e56cb18c58522d3 (diff)
downloadcatch3-1cbbc5d2cbac7f497fa5e2128f6779ee2e5fb510.tar.gz
Add test for !shouldfail and failed benchmarks
-rw-r--r--tests/CMakeLists.txt10
-rw-r--r--tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp5
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 750547c0..7f7c32fe 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -359,6 +359,16 @@ set_tests_properties("Benchmarking::FailureReporting::FailMacro"
FAIL_REGULAR_EXPRESSION "successes=\"1\""
)
+add_test(NAME "Benchmarking::FailureReporting::ShouldFailIsRespected"
+ COMMAND
+ $<TARGET_FILE:SelfTest> "Failing benchmark respects should-fail"
+)
+set_tests_properties("Benchmarking::FailureReporting::ShouldFailIsRespected"
+ PROPERTIES
+ PASS_REGULAR_EXPRESSION "1 failed as expected"
+)
+
+
if (CATCH_USE_VALGRIND)
add_test(NAME ValgrindRunTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest>)
add_test(NAME ValgrindListTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest> --list-tests --verbosity high)
diff --git a/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp b/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp
index b2250415..19fa8f95 100644
--- a/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp
@@ -433,3 +433,8 @@ TEST_CASE("Failing benchmarks", "[!benchmark][.approvals]") {
};
}
}
+
+TEST_CASE( "Failing benchmark respects should-fail",
+ "[!shouldfail][!benchmark][.approvals]" ) {
+ BENCHMARK( "Asserting benchmark" ) { REQUIRE( 1 == 2 ); };
+}