4762 Commits

Author SHA1 Message Date
Martin Hořeňovský 9ec44dd62b catch_discover_tests uses tempfile to retrieve JSON from the binary
This allows it to deal with badly behaved code, where 3rd party
dependencies write into stdout during global construction.

Closes #3162
Closes #3166
2026-07-04 16:36:05 +02:00
Martin Hořeňovský 675f9eaeb1 Add LLM policy to contributing.md 2026-06-14 20:25:57 +02:00
Martin Hořeňovský bcfb10e498 v3.15.1 v3.15.1 2026-06-14 10:57:30 +02:00
Dominic Koepke b7e0310fbe fix: move struct TestName of INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2 into the anonymous namespace 2026-06-09 19:17:14 +02:00
Dominic Koepke 6d4ea62200 fix: move struct TestName of INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2 into the anonymous namespace 2026-06-09 19:17:14 +02:00
offa 195231c59a docs: Set missing syntax language 2026-05-31 17:17:46 +02:00
offa 3a865e8c0f docs: Enable syntax coloring for code example 2026-05-31 17:17:46 +02:00
Dirk Müller 69e0473f6e Avoid a potential underflow when iterating over invalid inputs
The forward iteration logic already bounds-check for m_it != m_string->end(),
do the same for the backward iteration. The issue with the assert is
that the assert() might not be compiled in, and it is happening after
the dereference, so it was too late.
2026-05-14 10:58:09 +02:00
Martin Hořeňovský 6ee0826dca v3.15.0 v3.15.0 2026-05-12 13:16:46 +02:00
Martin Hořeňovský 47ea57d74f Constexpr matching support in the range equals matchers 2026-05-12 11:05:33 +02:00
Martin Hořeňovský d838f88b9c Constexpr matching support in generic Contains matchers 2026-05-12 11:05:31 +02:00
Martin Hořeňovský c267b6eb4d Constexpr matching support in the quantifier matchers 2026-05-12 11:05:31 +02:00
Martin Hořeňovský 3cdae5faf0 Constexpr matching support in IsEmpty and SizeIs matchers 2026-05-12 11:05:29 +02:00
Martin Hořeňovský 651247c7f4 Support for constexpr matchers in C++20 (P0784)
To make this all work, I had to remove the stringification cache
from matchers. In theory, this can cause performance penalty in
cases where single matcher instance is stringified multiple times,
but in practice this does not happen much, and the difference is
surprisingly small anyway, because the performance of stringification
is already horrible and full of allocating strings just to throw
them away.

The matcher combinators need P2738 from C++26 to be `constexpr`.

Closes #3091
2026-05-12 11:05:02 +02:00
Martin Hořeňovský 15b9393f0f Don't check if __cplusplus is defined 2026-05-10 20:48:58 +02:00
Martin Hořeňovský a18badd10f Workaround P3168 causing ambiguous overload issues with StringMaker
P3168 turned `std::optional` into a range type, so the partial specialization
of `StringMaker` for `std::optional<T>` conflicted with the partial
specialization for range types. Ideally we will fix this in the future
to support user-provided partial specializations for range-like types,
but for now we just disable the partial specialization for `std::optional<T>`
if P3168 is implemented.
2026-05-09 22:24:12 +02:00
Martin Hořeňovský 54af40652a Add more runtime benchmark recipe TODOs 2026-05-07 21:13:11 +02:00
Martin Hořeňovský 5f47160bb2 Add benchmark for catch_test_macros.hpp inclusion 2026-05-07 20:27:09 +02:00
Martin Hořeňovský e83528c6eb Add readme to benchmarks/ with some simple examples 2026-05-07 10:43:24 +02:00
Martin Hořeňovský fd31a62547 Add benchmark for REQUIRE_THAT into runtime_assertion_benches.cpp
I also changed the names of other benchmark `TEST_CASE`s so that
they are easier to use.
2026-05-07 10:18:21 +02:00
Martin Hořeňovský 4df8fee92d IConfig derives from NonCopyable privately 2026-05-07 10:12:28 +02:00
Ole Schmidt 300c5d3eed Fix Wconversion warning in catch_reporter_helpers.cpp 2026-05-06 09:58:01 +02:00
Martin Hořeňovský 11a96e186a Cleanups from static analysis 2026-04-24 11:21:04 +02:00
Martin Hořeňovský 10f62484bf AssertionHandler uses RunContext directly to avoid virtual dispatch 2026-04-13 22:56:55 +02:00
Martin Hořeňovský be2dfb45cc Update Doxyfile 2026-04-08 15:06:36 +02:00
Martin Hořeňovský 47200ddbee Rework internals of CATCH_REGISTER_ENUM
The old internals reached into the global hub to stash the allocation(s)
for enum value -> string value there, then kept around a potentially
invalid (in case the hub was cleaned up) reference into it, going through
whole bunch of virtual dispatch in the process.

The new internals just store the data in a static variable inside the
`StringMaker` specialization. This avoids potential lifetime issues,
avoids all virtual dispatch and (almost) reduces the include bloat in
the main header path.

The reason for (almost) there is that for full include correctness,
`EnumInfo` needs `<utility>` include for `std::pair`. However, this brings
in things like `std::relops`, because the std headers in C++ are dumb.
As this was not included before, and instead we relied on `std::pair`
existing in an internal stdlib header that we transitively included, the
full include size ends up bigger than before.
2026-04-08 12:57:09 +02:00
Martin Hořeňovský e51dcdcc59 Mark TestInvoker{AsMethod,Fixture} as final 2026-04-07 14:36:08 +02:00
Martin Hořeňovský 77eae8bd2a Turn IResultCapture::lastAssertionPassed into a free function
The thread-safety changes in assertions & messages turned whether
the last assertion passed or failed into thread-local state,
instead of being member of the `RunContext`. However, this change
was not reflected in the API `CHECKED_IF`/`CHECKED_ELSE` used,
which in turn required `catch_test_macro_impl.hpp` to include
`catch_interfaces_capture.hpp` for it.

Thanks to the combination of this commit and the previous similar
commit for the message stack handling, the main include path does
not need to include `catch_interfaces_capture.hpp` anymore.
2026-04-07 14:33:39 +02:00
Martin Hořeňovský 3ab0d7cef3 Turn IResultCapture::{push,pop}*Message into free functions
The thread-safety changes in assertions & messages turned the message
stacks into thread-local state, instead of it being member of `RunContext`.
The relevant {push,pop}(Un)ScopedMessage functions were turned from member
functions into static functions, but this left `catch_message.hpp` with
dependency on `IResultCapture`'s definition for the functions, and thus
it still had to include `catch_interfaces_capture.hpp`.

With this change, `catch_message.hpp` no longer needs
`catch_interfaces_capture.hpp`.
2026-04-07 14:28:11 +02:00
Martin Hořeňovský e83218c2df Move all use of IResultCapture in AssertionHandler into the cpp file
This has two advantages

1) Removing the include of `catch_interfaces_capture.hpp` from the
   header and potentially allowing further pruning later.
2) Providing small-but-measurable 1-2% speedup for assertions.
2026-04-07 09:32:07 +02:00
Martin Hořeňovský 548e14a8c8 Mark some extra classes final 2026-04-07 00:13:17 +02:00
Martin Hořeňovský b670de4fe1 v3.14.0 v3.14.0 2026-04-05 15:05:38 +02:00
Martin Hořeňovský 465e63dad7 Do not include chrono_clock.hpp in benchmark_stats_fwd.hpp 2026-04-05 14:57:05 +02:00
Christoph Grüninger 34f4f81947 [ci] Update GitHub Actions to latest major release
Fix warning that Node.js 20 is disconinued in June
2026-04-04 22:28:48 +02:00
Martin Hořeňovský 57f738b380 JUnit reporter output single failed assertion node per test case
Ideally JUnit tools would handle multiple failures per test case,
but they don't, so here we are.

Closes #1919
2026-04-04 15:12:56 +02:00
Martin Hořeňovský 1df10d28ae Don't write semicolon after failed expression in separate call 2026-04-03 10:28:32 +02:00
Martin Hořeňovský 9f1b48a94f Inline SKIP/FAIL in RunContext to fix build failure with prefixed macros
Closes #3087
2026-04-03 10:19:05 +02:00
Sung, Po Han f4e83daa18 Fix catch_discover_tests PRE_TEST failure with zero discoverable tests
When using catch_discover_tests() with DISCOVERY_MODE PRE_TEST and a
multi-config generator (e.g. Ninja Multi-Config), if a test target has
zero discoverable tests (e.g. all tests tagged with [.]), ctest fails:

  CMake Error: include could not find requested file:
    .../test-hidden-b12d07c_tests-Release.cmake

The early return added in #2962 (76f70b14) correctly prevented a JSON
parsing crash for zero tests, but skipped writing the ctest file. The
PRE_TEST include script unconditionally includes this file, so the
missing file causes a hard error that aborts all test discovery.

Write an empty file before returning early so the include always
succeeds.
2026-04-02 10:24:46 +02:00
Jan Niklas Hasse 572f96b8fe Fix counting of UTF-8 codepoints in TextFlow
For line-wrapping bytes were counted instead of codepoints. This
resulted in line-breaks being inserted at the wrong position and also
breaking UTF-8 characters.

Fixes #1022.
2026-04-01 16:12:08 +02:00
Martin Hořeňovský 8492fd444e Ignore Wunreachable-code-return in Generators.tests.cpp 2026-04-01 11:02:56 +02:00
Martin Hořeňovský fe2a20ab55 Fix warning suppression block in Condition.tests straddling includes 2026-04-01 10:56:21 +02:00
Martin Hořeňovský 51b0532d1f Suppress __COUNTER__ warning from newest Clang versions
Ideally we could suppress the warning locally in the `UNIQUE_NAME` macro,
but that runs into at least 2 issues:

1) Clang actually does not consider the warning as coming from inside the
   `UNIQUE_NAME` macro, even though it correctly points to its expansion
   as the problem. This means that adding `_Pragma`s inside the macro
   around the __COUNTER__ usage does not actually silence the warning.

2) Adding the local suppressions anyway breaks the expansion of
   `MAKE_NAMESPACE` macro inside the templated test case macros. This can
   be fixed for the newest clang version by removing its use and using
   the uniqued `TestName` for the namespace name directly, but this breaks
   compilation on GCC, and older Clang versions.

Because of these issues, we introduce global warning suppression for
`-Wc2y-extensions` to be done with it. We should revisit this if Clang 23
fixes the local pragma based suppression, when it might be worth the effort
to rework the templated test case macros to support it.

Closes #3076
2026-04-01 10:34:58 +02:00
Joseph Edwards 2ec64d12b1 fix: add missing backslash in macro definition 2026-03-30 14:23:17 +02:00
Martin Hořeňovský ccc49ba664 Merge pull request #3078 from e-kwsm/cstdint
fix: add missed <cstdint> inclusion
2026-03-11 13:44:52 +01:00
Eisuke Kawashima 6f036244e9 fix: add missed <cstdint> inclusion 2026-03-08 19:34:59 +09:00
Vertexwahn 50e9dbfc4e Update bazel_skylib and rules_cc dependencies 2026-02-18 20:14:05 +01:00
Martin Hořeňovský a404f37cec Add quiet verbosity variant to the default listener and tag listing 2026-02-16 22:52:39 +01:00
Martin Hořeňovský 29c9844f68 v3.13.0 v3.13.0 2026-02-15 22:55:48 +01:00
Martin Hořeňovský 56024c04e4 More tests for MapGenerator 2026-02-15 21:53:10 +01:00
Martin Hořeňovský edfed6c04e Efficient skipToNthElementImpl for Take and Map generators 2026-02-15 21:43:54 +01:00