expression-formatter.h File
C++ header file with declarations for the µTest++ expression formatter. More...
Included Headers
Namespaces Index
| namespace | micro_os_plus |
|
The primary namespace for the µOS++ framework. More... | |
| namespace | micro_test_plus |
|
Primary namespace for the µTest++ testing framework. More... | |
| namespace | detail |
|
Internal implementation details for the µTest++ framework. More... | |
Classes Index
| struct | colour_code |
|
An ANSI colour escape sequence, to be written as it is. More... | |
| struct | colours |
|
Colours used to highlight pass and fail results in test reports. More... | |
| class | expression_formatter |
|
Formats values and expressions into an owned string buffer. More... | |
| struct | plain_text |
|
Writes values as text, as the messages of the checks are written. More... | |
Concepts Index
| concept | free_printable |
|
Concept satisfied by the types that have a free operator<< for the formatter. More... | |
| concept | member_printable |
|
Concept satisfied by the types that the formatter writes with one of its own member functions operator<<. More... | |
Typedefs Index
| using | expression_formatter = detail::expression_formatter |
|
Public name of the formatter used to report operand values. More... | |
Functions Index
| void | append_control_escape (std::string &text, char c) |
|
Appends the escape sequence of a control character. More... | |
Variables Index
| constexpr colours | colours_none {} |
|
Predefined colour set, without escape sequences. More... | |
| constexpr colours | colours_red_green = ... |
|
Predefined colour set, with green for pass and red for fail. More... | |
Description
C++ header file with declarations for the µTest++ expression formatter.
This header provides the expression_formatter class, which encapsulates all value-formatting logic used by the µTest++ framework. The class owns a std::string buffer and exposes operator<< overloads for every standard arithmetic type, character type, string, pointer, container, scoped enumeration, pair, tuple, optional, and framework expression type (see extension::is_op).
By consolidating the formatting operators into a single class (using the shared detail::append_number() helper for numbers), the reporter is relieved of those responsibilities, and detail::check_result can pre-format expression text, when initialised, without requiring reporter or test_case to be complete at that point.
The formatter shares the colour configuration of the owning reporter: comparator expressions are wrapped in pass/fail colour codes, which are empty strings unless the reporter enables colours.
All definitions reside within the micro_os_plus::micro_test_plus namespace.
This file is included by micro-os-plus/micro-test-plus.h, which is the header that the applications include.
Functions
append_control_escape()
|
Appends the escape sequence of a control character.
Writes the usual escape of the character (\\0, \\a, \\b, \\t, \\n, \\v, \\f, or \\r), or \\xHH for the other ones. Used for the characters of the messages and of the names that would otherwise reach the console and the output files unchanged. Defined in src/expression-formatter.cpp.
- Parameters
-
text The text to append to.
c The control character.
The usual escapes for the characters that have one; the other ones, including DEL, as \\xHH.
Definition at line 401 of file expression-formatter.cpp.
Reference micro_os_plus::micro_test_plus::detail::append_control_escape.
Referenced by micro_os_plus::micro_test_plus::detail::append_control_escape, micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_plain, micro_os_plus::micro_test_plus::detail::escape_control_characters and micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<.
Variables
colours_none
| constexpr |
Predefined colour set, without escape sequences.
Used by the formatters that write the messages of the checks, which are never coloured; all members are empty strings.
Definition at line 184 of file expression-formatter.h.
Referenced by micro_os_plus::micro_test_plus::detail::expression_formatter::expression_formatter and micro_os_plus::micro_test_plus::detail::expression_formatter::expression_formatter.
colours_red_green
| constexpr |
Predefined colour set, with green for pass and red for fail.
- Initialiser
-
= { "\033[0m", "\033[32m", "\033[31m" }
Assigned by reporters that output to a colour-capable terminal; the members are, in order, the reset, pass, and fail ANSI escape sequences.
Definition at line 171 of file expression-formatter.h.
Referenced by micro_os_plus::micro_test_plus::detail::reporter_human::reporter_human.
File Listing
The file content with the documentation metadata removed is:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.