catch2/3.5.1+1

[brief]

Catch2 is a multi-paradigm test framework for C++. which also supports Objective-C (and maybe C). It is primarily distributed as a single header file, although certain extensions may require additional headers.

Catch2 logo

Github Releases Linux build status Linux build status MacOS build status Build Status Code Coverage Try online Join the chat in Discord: https://discord.gg/4CWS9zD

What is Catch2?

Catch2 is mainly a unit testing framework for C++, but it also provides basic micro-benchmarking features, and simple BDD macros.

Catch2's main advantage is that using it is both simple and natural. Test names do not have to be valid identifiers, assertions look like normal C++ boolean expressions, and sections provide a nice and local way to share set-up and tear-down code in tests.

Example unit test

#include <catch2/catch_test_macros.hpp>

#include <cstdint>

uint32_t factorial( uint32_t number ) {
    return number <= 1 ? number : factorial(number-1) * number;
}

TEST_CASE( "Factorials are computed", "[factorial]" ) {
    REQUIRE( factorial( 1) == 1 );
    REQUIRE( factorial( 2) == 2 );
    REQUIRE( factorial( 3) == 6 );
    REQUIRE( factorial(10) == 3'628'800 );
}

Example microbenchmark

#include <catch2/catch_test_macros.hpp>
#include <catch2/benchmark/catch_benchmark.hpp>

#include <cstdint>

uint64_t fibonacci(uint64_t number) {
    return number < 2 ? number : fibonacci(number - 1) + fibonacci(number - 2);
}

TEST_CASE("Benchmark Fibonacci", "[!benchmark]") {
    REQUIRE(fibonacci(5) == 5);

    REQUIRE(fibonacci(20) == 6'765);
    BENCHMARK("fibonacci 20") {
        return fibonacci(20);
    };

    REQUIRE(fibonacci(25) == 75'025);
    BENCHMARK("fibonacci 25") {
        return fibonacci(25);
    };
}

Note that benchmarks are not run by default, so you need to run it explicitly with the [!benchmark] tag.

Catch2 v3 has been released!

You are on the devel branch, where the v3 version is being developed. v3 brings a bunch of significant changes, the big one being that Catch2 is no longer a single-header library. Catch2 now behaves as a normal library, with multiple headers and separately compiled implementation.

The documentation is slowly being updated to take these changes into account, but this work is currently still ongoing.

For migrating from the v2 releases to v3, you should look at our documentation. It provides a simple guidelines on getting started, and collects most common migration problems.

For the previous major version of Catch2 look into the v2.x branch here on GitHub.

How to use it

This documentation comprises these three parts:

More

version 3.5.1+1
license BSL-1.0
repository https://pkg.cppget.org/1/stable
download catch2-3.5.1+1.tar.gz
sha256 02b088fd79b379671d151835ff9eda68a8d0a9ba3273785c21013dff41e833cd
project catch2
url github.com/catchorg/Catch2

Requires (1)

c++14

Tests

catch2-tests == 3.5.1

Examples

catch2-examples == 3.5.1

Reviews

fail 0
pass 1

Builds

toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_fedora_44-gcc_16-bindist
timestamp 2026-05-18 10:18:33 UTC (03 06:38:43 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-apple-darwin23.5.0
tgt config macos_14-gcc_14_homebrew-static_O3
timestamp 2026-05-13 11:58:39 UTC (08 04:58:37 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-apple-darwin23.5.0
tgt config macos_14-gcc_14_homebrew-O3
timestamp 2026-05-13 11:55:46 UTC (08 05:01:31 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-apple-darwin23.5.0
tgt config macos_14-gcc_14_homebrew
timestamp 2026-05-13 11:52:24 UTC (08 05:04:52 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-apple-darwin23.5.0
tgt config macos_14-clang_15.0-static_O3
timestamp 2026-05-13 11:45:59 UTC (08 05:11:18 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-apple-darwin23.5.0
tgt config macos_14-clang_15.0-O3
timestamp 2026-05-13 11:43:19 UTC (08 05:13:58 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-apple-darwin23.5.0
tgt config macos_14-clang_15.0
timestamp 2026-05-13 11:40:37 UTC (08 05:16:40 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_14-static_O3
timestamp 2026-05-13 11:31:53 UTC (08 05:25:23 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_14-ndebug_O3
timestamp 2026-05-13 11:31:02 UTC (08 05:26:14 days ago)
result success | log | rebuild
toolchain public-0.18.1
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_14-O3
timestamp 2026-05-13 11:27:07 UTC (08 05:30:10 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target aarch64-linux-gnu
tgt config linux_debian_12-clang_18_libc++-O3
timestamp 2026-05-13 11:25:11 UTC (08 05:32:05 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target aarch64-linux-gnu
tgt config linux_debian_12-clang_18_libc++-static_O3
timestamp 2026-05-13 11:24:34 UTC (08 05:32:43 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_14
timestamp 2026-05-13 11:23:04 UTC (08 05:34:13 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target aarch64-linux-gnu
tgt config linux_debian_12-clang_18_libc++
timestamp 2026-05-13 11:22:14 UTC (08 05:35:02 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target aarch64-linux-gnu
tgt config linux_debian_12-clang_18-static_O3
timestamp 2026-05-13 11:21:42 UTC (08 05:35:34 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target aarch64-linux-gnu
tgt config linux_debian_12-clang_18-O3
timestamp 2026-05-13 11:19:38 UTC (08 05:37:38 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target aarch64-linux-gnu
tgt config linux_debian_12-clang_18
timestamp 2026-05-13 11:19:23 UTC (08 05:37:53 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_fedora_43-gcc_15-bindist
timestamp 2026-05-13 10:49:09 UTC (08 06:08:07 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-freebsd15.0
tgt config freebsd_15-clang_19
timestamp 2026-05-13 10:48:59 UTC (08 06:08:18 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-freebsd15.0
tgt config freebsd_15-clang_19-O3
timestamp 2026-05-13 10:46:14 UTC (08 06:11:03 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_15.0
timestamp 2026-05-13 10:46:05 UTC (08 06:11:12 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_ubuntu_24.04-gcc_13-bindist
timestamp 2026-05-13 10:43:52 UTC (08 06:13:24 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-gcc_14-bindist
timestamp 2026-05-13 10:43:42 UTC (08 06:13:35 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-freebsd15.0
tgt config freebsd_15-clang_19-static_O3
timestamp 2026-05-13 10:43:08 UTC (08 06:14:08 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-gcc_15-O3
timestamp 2026-05-13 10:41:42 UTC (08 06:15:35 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-gcc_15
timestamp 2026-05-13 10:38:22 UTC (08 06:18:55 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-freebsd14.1
tgt config freebsd_14-clang_18
timestamp 2026-05-13 10:35:59 UTC (08 06:21:18 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_13
timestamp 2026-05-13 10:35:10 UTC (08 06:22:07 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-clang_22_libc++-static_O3
timestamp 2026-05-13 10:13:43 UTC (08 06:43:33 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-clang_22_libc++-O3
timestamp 2026-05-13 10:13:42 UTC (08 06:43:34 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-clang_22_libc++
timestamp 2026-05-13 10:12:26 UTC (08 06:44:51 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-clang_22-O3
timestamp 2026-05-13 10:11:41 UTC (08 06:45:36 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-clang_22-static_O3
timestamp 2026-05-13 10:11:28 UTC (08 06:45:48 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-clang_22
timestamp 2026-05-13 10:10:00 UTC (08 06:47:17 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-gcc_16-static_O3
timestamp 2026-05-13 10:08:44 UTC (08 06:48:32 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-gcc_16-ndebug_O3
timestamp 2026-05-13 10:08:13 UTC (08 06:49:04 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-gcc_16-O3
timestamp 2026-05-13 10:07:56 UTC (08 06:49:20 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-gcc_16
timestamp 2026-05-13 10:06:52 UTC (08 06:50:24 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-clang_21_libc++
timestamp 2026-05-13 10:06:03 UTC (08 06:51:13 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_debian_13-clang_21
timestamp 2026-05-13 10:05:48 UTC (08 06:51:29 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-microsoft-win32-msvc14.5
tgt config windows_10-msvc_18-static_O2
timestamp 2026-05-11 08:30:33 UTC (10 08:26:44 days ago)
result success | log | rebuild
toolchain public-0.18.1
target x86_64-microsoft-win32-msvc14.5
tgt config windows_10-msvc_18-O2
timestamp 2026-05-11 08:28:31 UTC (10 08:28:46 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-microsoft-win32-msvc14.5
tgt config windows_10-clang_21_msvc_18-O2
timestamp 2026-05-11 08:28:03 UTC (10 08:29:13 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-microsoft-win32-msvc14.5
tgt config windows_10-msvc_18
timestamp 2026-05-11 08:28:02 UTC (10 08:29:15 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-microsoft-win32-msvc14.5
tgt config windows_10-clang_21_msvc_18
timestamp 2026-05-11 08:27:58 UTC (10 08:29:18 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-microsoft-win32-msvc14.5
tgt config windows_10-clang_21_msvc_18-static_O2
timestamp 2026-05-11 08:27:49 UTC (10 08:29:28 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-msvc_17
timestamp 2026-05-11 08:04:57 UTC (10 08:52:19 days ago)
result error (test) | log | rebuild
toolchain public-0.18.1
target x86_64-w64-mingw32
tgt config windows_10-gcc_15.2_mingw_w64-static_O2
timestamp 2026-05-08 11:12:05 UTC (13 05:45:12 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-w64-mingw32
tgt config windows_10-gcc_15.2_mingw_w64-O2
timestamp 2026-05-08 11:11:59 UTC (13 05:45:18 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-w64-mingw32
tgt config windows_10-gcc_15.2_mingw_w64
timestamp 2026-05-08 11:11:29 UTC (13 05:45:47 days ago)
result warning (test) | warning (test-installed) | log | rebuild
toolchain public-0.18.1
target x86_64-linux-gnu
tgt config linux_ubuntu_26.04-gcc_15-bindist
timestamp 2026-05-08 11:08:12 UTC (13 05:49:04 days ago)
result warning (test) | warning (test-installed) | log | rebuild