mcpp index

compat.catch2

#include

A modern, C++-native test framework for unit-tests, TDD and BDD

#include <catch2/catch_all.hpp>
mcpp add compat.catch2@3.15.2

用法

来自本仓库自己的测试项目 —— CI 真的编译并运行过,不是为了网站写的。

// compat.catch2 v3, `main` FEATURE: no main() here on purpose — the entry
// point comes from the package's generated TU. Catch2 prints the assertion
// count on exit, so an empty binary cannot pass quietly.
#include <catch2/catch_all.hpp>

static unsigned int factorial(unsigned int n) {
    return n <= 1 ? 1 : n * factorial(n - 1);
}

TEST_CASE("factorial of 5 is 120", "[math]") {
    REQUIRE(factorial(5) == 120);
}

TEST_CASE("factorial of 0 is 1", "[math]") {
    REQUIRE(factorial(0) == 1);
}

tests/examples/catch2-main/tests/main.cpp · 项目 tests/examples/catch2-main

openkal

目标结果环境测试项目首条诊断
x86_64-linux-gnurunsposixcatch2
x86_64-windows-muslrunsposixcatch2

测量方式

2026-09-23 由 tests/openkal/compat.py 测得,使用 openkal-llvm-runtime 0.15.1、llvm@22.1.8、mcpp 2026.9.21.3。测试项目没有自行选择平台依赖。 上方徽章是所有已测目标里最严格那个的结果 —— 上表列出每个目标各自的环境。

构建

targets
catch2 (lib)
language
c++23
C standard
c11
import std
no
include dirs
mcpp_generated, */single_include, */src

特性

特性声明了
mainsources

源文件 (3)

  • mcpp_generated/catch2_anchor.c
  • */src/catch2/**/*.cpp
  • !*/src/catch2/internal/catch_main.cpp

生成的文件

  • mcpp_generated/catch2_main.cpp
  • mcpp_generated/catch2/catch.hpp
  • mcpp_generated/catch2/catch_user_config.hpp
  • mcpp_generated/catch2_anchor.c

版本

版本平台 镜像sha256
3.15.2 最新 LinuxWindowsmacOS CN GLOBAL acfae120892c…
2.13.10 LinuxWindowsmacOS CN GLOBAL d54a712b7b1d…