File tree Expand file tree Collapse file tree 5 files changed +88
-2
lines changed Expand file tree Collapse file tree 5 files changed +88
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ cmake_dependent_option(CATCH_BUILD_TESTING "Build the SelfTest project" ON "CATC
20
20
cmake_dependent_option(CATCH_BUILD_EXAMPLES "Build code examples" OFF "CATCH_DEVELOPMENT_BUILD" OFF )
21
21
cmake_dependent_option(CATCH_BUILD_EXTRA_TESTS "Build extra tests" OFF "CATCH_DEVELOPMENT_BUILD" OFF )
22
22
cmake_dependent_option(CATCH_BUILD_FUZZERS "Build fuzzers" OFF "CATCH_DEVELOPMENT_BUILD" OFF )
23
+ cmake_dependent_option(CATCH_BUILD_BENCHMARKS "Build the benchmarks" OFF "CATCH_DEVELOPMENT_BUILD" OFF )
23
24
cmake_dependent_option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF "CATCH_DEVELOPMENT_BUILD" OFF )
24
25
cmake_dependent_option(CATCH_ENABLE_WERROR "Enables Werror during build" ON "CATCH_DEVELOPMENT_BUILD" OFF )
25
26
cmake_dependent_option(CATCH_BUILD_SURROGATES "Enable generating and building surrogate TUs for the main headers" OFF "CATCH_DEVELOPMENT_BUILD" OFF )
@@ -77,6 +78,11 @@ set(SELF_TEST_DIR ${CATCH_DIR}/tests/SelfTest)
77
78
# We need to bring-in the variables defined there to this scope
78
79
add_subdirectory (src)
79
80
81
+ if (CATCH_BUILD_BENCHMARKS)
82
+ set (CMAKE_FOLDER "benchmarks" )
83
+ add_subdirectory (benchmarks)
84
+ endif ()
85
+
80
86
# Build tests only if requested
81
87
if (BUILD_TESTING AND CATCH_BUILD_TESTING AND NOT_SUBPROJECT)
82
88
find_package (Python3 REQUIRED COMPONENTS Interpreter)
Original file line number Diff line number Diff line change 15
15
}
16
16
},
17
17
{
18
- "name" : " all -tests" ,
18
+ "name" : " most -tests" ,
19
19
"inherits" : " basic-tests" ,
20
20
"displayName" : " Full development build" ,
21
- "description" : " Enables development build with examples and ALL tests" ,
21
+ "description" : " Enables development build with extended set of tests (still relatively cheap to build) " ,
22
22
"cacheVariables" : {
23
23
"CATCH_BUILD_EXAMPLES" : " ON" ,
24
24
"CATCH_BUILD_EXTRA_TESTS" : " ON" ,
25
25
"CATCH_BUILD_SURROGATES" : " ON" ,
26
+ "CATCH_BUILD_BENCHMARKS" : " ON"
27
+ }
28
+ },
29
+ {
30
+ "name" : " all-tests" ,
31
+ "inherits" : " most-tests" ,
32
+ "displayName" : " Full development build" ,
33
+ "description" : " Enables development build with examples and ALL tests" ,
34
+ "cacheVariables" : {
26
35
"CATCH_ENABLE_CONFIGURE_TESTS" : " ON" ,
27
36
"CATCH_ENABLE_CMAKE_HELPER_TESTS" : " ON"
28
37
}
Original file line number Diff line number Diff line change
1
+ include (CatchMiscFunctions)
2
+
3
+ add_executable (AssertionsFastPath
4
+ runtime_assertion_benches.cpp
5
+ )
6
+
7
+ add_executable (AssertionsSlowPath
8
+ runtime_assertion_benches.cpp
9
+ assertion_listener.cpp
10
+ )
11
+
12
+ target_link_libraries (AssertionsFastPath PRIVATE Catch2::Catch2WithMain)
13
+ target_link_libraries (AssertionsSlowPath PRIVATE Catch2::Catch2WithMain)
14
+
15
+ list (APPEND CATCH_TEST_TARGETS AssertionsFastPath AssertionsSlowPath)
16
+ set (CATCH_TEST_TARGETS ${CATCH_TEST_TARGETS} PARENT_SCOPE)
Original file line number Diff line number Diff line change
1
+
2
+ // Copyright Catch2 Authors
3
+ // Distributed under the Boost Software License, Version 1.0.
4
+ // (See accompanying file LICENSE.txt or copy at
5
+ // https://www.boost.org/LICENSE_1_0.txt)
6
+
7
+ // SPDX-License-Identifier: BSL-1.0
8
+
9
+ #include < catch2/reporters/catch_reporter_event_listener.hpp>
10
+ #include < catch2/reporters/catch_reporter_registrars.hpp>
11
+
12
+ /* *
13
+ * Event listener that listens to all assertions, forcing assertion slow path
14
+ */
15
+ class AssertionSlowPathListener : public Catch ::EventListenerBase {
16
+ public:
17
+ static std::string getDescription () {
18
+ return " Validates ordering of Catch2's listener events" ;
19
+ }
20
+
21
+ AssertionSlowPathListener (Catch::IConfig const * config) :
22
+ EventListenerBase (config) {
23
+ m_preferences.shouldReportAllAssertions = true ;
24
+ m_preferences.shouldReportAllAssertionStarts = true ;
25
+ }
26
+ };
27
+
28
+ CATCH_REGISTER_LISTENER ( AssertionSlowPathListener )
Original file line number Diff line number Diff line change
1
+
2
+ // Copyright Catch2 Authors
3
+ // Distributed under the Boost Software License, Version 1.0.
4
+ // (See accompanying file LICENSE.txt or copy at
5
+ // https://www.boost.org/LICENSE_1_0.txt)
6
+
7
+ // SPDX-License-Identifier: BSL-1.0
8
+
9
+ #include < catch2/catch_test_macros.hpp>
10
+
11
+ TEST_CASE (" Simple REQUIRE - 10M" ) {
12
+ for (size_t i = 0 ; i < 10'000'000 ; ++i) {
13
+ REQUIRE (true );
14
+ }
15
+ }
16
+
17
+ TEST_CASE (" Simple NOTHROW - 10M" ) {
18
+ for (size_t i = 0 ; i < 10'000'000 ; ++i) {
19
+ REQUIRE_NOTHROW ([](){}());
20
+ }
21
+ }
22
+
23
+ TEST_CASE (" Simple THROWS - 10M" ) {
24
+ for (size_t i = 0 ; i < 10'000'000 ; ++i) {
25
+ REQUIRE_THROWS ([]() { throw 1 ; }());
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments