|
micro-test-plus 6.0.0
µTest++ Testing Framework
|
Reporting the application types, and writing application comparators. More...
Concepts | |
| concept | micro_os_plus::micro_test_plus::extension::any_op |
| Concept satisfied when at least one of two types is a framework expression type. | |
| concept | micro_os_plus::micro_test_plus::extension::approx_operand |
| Concept satisfied when T is a valid operand of the approximate comparator. | |
| concept | micro_os_plus::micro_test_plus::extension::checkable |
| Concept satisfied when a type can be used as a test expression in expect() or require(). | |
| concept | micro_os_plus::micro_test_plus::extension::compare_tag |
| Concept satisfied by a tag that defines a custom comparator. | |
| concept | micro_os_plus::micro_test_plus::extension::is_op |
| Concept satisfied when a type is a framework expression type. | |
| concept | micro_os_plus::micro_test_plus::extension::predicate_tag |
| Concept satisfied by a tag that defines a custom predicate. | |
| concept | micro_os_plus::micro_test_plus::extension::printable |
| Concept satisfied when a type can be appended to the message of a check result via operator<<. | |
Typedefs | |
| using | micro_os_plus::micro_test_plus::expression_formatter = detail::expression_formatter |
| Public name of the formatter used to report operand values. | |
The applications extend the framework in two ways, both with public names only: they teach the formatter to write the values of their own types, and they write their own comparators and predicates, which are reported as the built-in ones.
The concepts of the extension namespace (is_op, any_op, checkable, printable, compare_tag, predicate_tag, and approx_operand) describe the types that these templates and the checks accept; the last one constrains the operands of approx(), for the helpers that forward their operands to it. Only the deprecated floating-point wrappers have a tolerance: with the deprecated definitions enabled, has_epsilon detects them, and a comparator tag may define a static constexpr bool within_tolerance_result, which is the result for the operands that are within the tolerance of such a wrapper; without it, the tolerance is ignored.
The failed checks are reported with the values and the symbol:
A predicate is written in the same way, with a tag that has a symbol and an apply() function of one operand, and the template extension::predicate_op. The report writes the symbol before the operand, so the symbol ends with the space that separates them ("is even "):
Both checks fail, and a predicate can be combined with negate(), all_of(), and any_of(), as the comparators are:
The function comparators and the custom operators report the values of their operands when a check fails. Values of user-defined types can be reported only if the application provides an operator<< that writes them to this formatter, declared in the namespace of the type, so that it is found by argument-dependent lookup:
Without such an operator, comparators such as eq() do not compile for user-defined types, since the operand values cannot be formatted; only the scoped enumerations are formatted without it, by their underlying value. Plain boolean checks, such as expect (a == b), do not need it, but they report only the source location on failure. The same operator also writes the values appended to the messages of the checks (expect (a == b) << "a is " << a).
Applications use the operator<< overloads, and str() to test their own operators; the functions that manage the buffer are private to the framework.
Definition at line 1824 of file expression-formatter.h.