Skip to main content

Test Cases

Test cases are named sequences of checks. More...

Classes Index

classsubtest

A named, runnable test case that lives inside a suite. More...

Description

Test cases are named sequences of checks.

Each test case is defined by calling suite::test() with a descriptive name and a callable object (typically a lambda accepting a subtest& reference), along with any optional arguments required for the test.

Test cases allow related checks to be organised together within the same environment, improving clarity and maintainability. Any number of test cases may be defined, each focusing on a specific aspect of the code under test.

By grouping checks in this way, developers can identify which functionality is being verified and interpret results in the context of overall software quality.

Examples
 
 // In main(), after tr.initialise():
 ts.test ("Check various conditions", [] (auto& t) {
  t.expect (mt::eq (compute_answer (), 42)) << "answer eq 42";
  t.expect (mt::ne (compute_answer (), 43)) << "answer ne 43";
 });
 
 ts.test ("Check various conditions with operators", [] (auto& t) {
  using namespace mt::operators;
  using namespace mt::literals;
 
  t.expect (compute_answer () == 42_i) << "answer == 42";
  t.expect (compute_answer () != 43_i) << "answer != 43";
 });

Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.