Aller au contenu
Bienvenue sur la nouvelle documentation de CppUtils !

Core test suite execution context providing assertion methods, builders, and test registration.

Instances are passed to test suite definitions configured via testSuite("SuiteName") = [](TestSuite& suite) { ... };. Supports regular tests, compile-time tests, parameterized tests (types, values, ranges), fuzz tests, and benchmarks.

using CppUtils::UnitTest::TestSuite::Logger = Logger<"UnitTests">;
using CppUtils::UnitTest::TestSuite::ValueTestBuilder = ParameterizedTestBuilder<std::tuple<Values...>>;
using CppUtils::UnitTest::TestSuite::RangeTestBuilder = ParameterizedTestBuilder<Range>;
std::vector<TestCase> tests;
[[nodiscard]] auto TestSuite::test(std::string name) -> TestBuilder;

Declares a test case with the specified name, returning a builder to configure and assign its body.

ParamètreDescription
nameDescriptive test name.

Retourne : TestBuilder instance.

template <auto Predicate>
auto TestSuite::test(std::string name) -> void;

Evaluates a test predicate at compile time via static_assert and registers it as a passed test.

The template predicate is evaluated at compile time: any assertion failure immediately breaks the build before the test executable is even run.

At runtime, this method registers an empty test body in the test runner so that the test appears in reports and metrics while avoiding the process isolation fork() overhead of runtime test cases. Prefer this overload when verifying constexpr functions, concepts, type traits, or template metaprogramming.

Paramètre templateDescription
PredicateConstexpr invocable returning a boolean or performing static assertions.
ParamètreDescription
nameDescriptive test name.
[[nodiscard]] auto TestSuite::fuzzTest(std::string name, std::size_t iterations) -> FuzzTestBuilder;

Registers a fuzz test executed for a specified number of randomized iterations.

ParamètreDescription
nameTest identifier.
iterationsNumber of iterations to run.

Retourne : FuzzTestBuilder for assigning the test body callback.