Fonctions & utilitaires
FUNCTIONSNamespace: CppUtils::UnitTest
Énumérations publiques
Section intitulée « Énumérations publiques »ComparisonOperator
Section intitulée « ComparisonOperator »enum class ComparisonOperator { Equal, NotEqual, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual};Relational comparison operators supported in assertion decomposition.
TestStatus
Section intitulée « TestStatus »enum class TestStatus { Success, Failure, Skipped};Outcome status of an individual test case execution.
Types publics
Section intitulée « Types publics »ComparisonOperatorMapping
Section intitulée « ComparisonOperatorMapping »using CppUtils::UnitTest::ComparisonOperatorMapping = typedef Type::Mapping<Type::Pair<ComparisonOperator::Equal, String::Hasher{"=="}>, Type::Pair<ComparisonOperator::NotEqual, String::Hasher{"!="}>, Type::Pair<ComparisonOperator::LessThan, String::Hasher{"<"}>, Type::Pair<ComparisonOperator::LessThanOrEqual, String::Hasher{"<="}>, Type::Pair<ComparisonOperator::GreaterThan, String::Hasher{">"}>, Type::Pair<ComparisonOperator::GreaterThanOrEqual, String::Hasher{">="}>>;Mapping between ComparisonOperator and its string representation.
ValueTestSuiteBuilder
Section intitulée « ValueTestSuiteBuilder »using CppUtils::UnitTest::ValueTestSuiteBuilder = typedef ParameterizedTestSuiteBuilder<std::tuple<Values...>>;Builder for registering a test suite parameterized over a discrete pack of values.
RangeTestSuiteBuilder
Section intitulée « RangeTestSuiteBuilder »using CppUtils::UnitTest::RangeTestSuiteBuilder = typedef ParameterizedTestSuiteBuilder<Range>;Builder for registering a test suite parameterized over an input range.
Constantes & variables
Section intitulée « Constantes & variables »Matcher tag variable template for expecting an exception of type ExceptionType.
Matcher instance asserting that an action completes without throwing any exception.
Matcher instance asserting that an action terminates abnormally.
Matcher instance asserting that a predicate eventually becomes true.
Matcher instance asserting that a future or reactive primitive completes.
Global test runner instance used for test suite registration and execution.
Fonctions publiques
Section intitulée « Fonctions publiques »constexpr auto getComparisonOperatorString(ComparisonOperator comparisonOperator) noexcept -> std::string_view;Converts a ComparisonOperator enumerator to its C++ operator string literal.
| Paramètre | Description |
|---|---|
comparisonOperator | Enumerator value. |
Retourne : Operator string view (e.g. "==", "<=", "!="), or empty string if invalid.
constexpr auto getComparisonOperator(std::string_view operatorString) noexcept -> std::optional<ComparisonOperator>;Parses an operator string literal into its corresponding ComparisonOperator.
| Paramètre | Description |
|---|---|
operatorString | Operator symbol string (e.g. "==", "<="). |
Retourne : ComparisonOperator wrapped in std::optional, or std::nullopt if unknown.
template <class OperandType>constexpr auto expect(OperandType&& operand, std::source_location location=std::source_location::current()) noexcept -> ExpectationProxy<OperandType>;Asserts an expectation on a value, condition, or callable.
Supports comparison assertions using relational operators:
expect(value) == expected;expect(score) >= 100;standalone boolean conditions:
expect(result.has_value());and matchers:
expect([&] { divide(1, 0); }) == throws<std::invalid_argument>;expect([&] { divide(1, 2); }) == noThrow;| Paramètre | Description |
|---|---|
operand | Value to compare, boolean condition, or callable to evaluate. |
location | Source location used for failure reporting (automatically captured). |
Retourne : ExpectationProxy evaluating the expectation.
Declares a test suite.
| Paramètre | Description |
|---|---|
name | Descriptive test suite identifier. |
Retourne : TestSuiteBuilder used to configure dependencies or assign suite body.
auto skip(std::string message, std::source_location location=std::source_location::current()) -> void;Deliberately skips the current test, reporting it as skipped in test results.
| Paramètre | Description |
|---|---|
message | Justification for skipping the test. |
location | Source location used for skip reporting (automatically captured). |
auto skipIf(bool condition, std::string message, std::source_location location=std::source_location::current()) -> void;Conditionally skips the current test if the provided condition evaluates to true.
| Paramètre | Description |
|---|---|
condition | Boolean flag determining whether to skip. |
message | Justification for skipping the test. |
location | Source location used for skip reporting (automatically captured). |
auto fail(std::string message="Explicit test failure", std::source_location location=std::source_location::current()) -> void;Explicitly fails the current test with a diagnostic message.
| Paramètre | Description |
|---|---|
message | Diagnostic description explaining why the test failed. |
location | Source location used for failure reporting (automatically captured). |
template <String::Hasher eventName = Type::Hash{}, class... Args, class Emitter>auto watch(Emitter& emitter);Creates an RAII EventWatcher to observe emitted events.
| Paramètre template | Description |
|---|---|
eventName | Hashed string identifying the event. |
Args | Payload parameter types. |
| Paramètre | Description |
|---|---|
emitter | Event emitter instance to subscribe to. |
Retourne : EventWatcher instance managing event subscription.
Times the synchronous execution of a callable.
| Paramètre | Description |
|---|---|
name | Diagnostic identifier of the benchmark. |
function | Callable to measure. |
Retourne : BenchmarkResult containing measured duration in nanoseconds.
auto compareBenchmarks(const BenchmarkResult& first, const BenchmarkResult& second) -> BenchmarkComparison;Compares two benchmark results, logs their relative speedup, and returns the comparison.
| Paramètre | Description |
|---|---|
first | First benchmark result (candidate). |
second | Second benchmark result (baseline). |
Retourne : BenchmarkComparison structure with speedup and relative performance analysis.
Emits a warning log if a candidate benchmark ran slower than a baseline benchmark.
| Paramètre | Description |
|---|---|
candidate | Benchmark result being evaluated. |
baseline | Reference benchmark result. |
auto fuzz(std::string name, std::size_t iterations, Type::Callable<Math::DeterministicRandomEngine &> auto&& function, std::uint64_t seed=Math::DeterministicRandomEngine::defaultSeed, std::source_location location=std::source_location::current()) -> void;Executes a fuzz testing loop passing a DeterministicRandomEngine to the test body.
| Paramètre | Description |
|---|---|
name | Descriptive identifier of the fuzz test. |
iterations | Number of iterations to execute. |
function | Test callback receiving a DeterministicRandomEngine&. |
seed | Initial pseudo-random number generator seed (defaults to DeterministicRandomEngine::defaultSeed). |
location | Source location used for failure reporting (automatically captured). |
Runs all registered test suites respecting dependency order and configuration settings.
| Paramètre | Description |
|---|---|
settings | Execution settings controlling verbose output, filtering, and abort conditions. |
Retourne : Exit code: 0 on success, non-zero if any test suite failed.
Parses command-line arguments into a TestSettings configuration object.
| Paramètre | Description |
|---|---|
arguments | Span of command-line argument tokens. |
Retourne : Parsed TestSettings configuration.
Parses standard main() arguments (argc, argv) into a TestSettings configuration object.
| Paramètre | Description |
|---|---|
argc | Argument count. |
argv | Array of argument strings. |
Retourne : Parsed TestSettings configuration.