micro-test-plus 6.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
expression-formatter.h File Reference

C++ header file with declarations for the µTest++ expression formatter. More...

#include "detail.h"
#include "extension.h"
#include <charconv>
#include <chrono>
#include <cstdio>
#include <optional>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include <string_view>
#include <version>
#include "inlines/expression-formatter-inlines.h"

Go to the source code of this file.

Classes

struct  micro_os_plus::micro_test_plus::detail::expression_formatter::colour_code
 An ANSI colour escape sequence, to be written as it is. More...
struct  micro_os_plus::micro_test_plus::detail::colours
 Colours used to highlight pass and fail results in test reports. More...
class  micro_os_plus::micro_test_plus::detail::expression_formatter
 Formats values and expressions into an owned string buffer. More...
struct  micro_os_plus::micro_test_plus::detail::plain_text
 Writes values as text, as the messages of the checks are written. More...

Namespaces

namespace  micro_os_plus
 The primary namespace for the µOS++ framework.
namespace  micro_os_plus::micro_test_plus
 Primary namespace for the µTest++ testing framework.
namespace  micro_os_plus::micro_test_plus::detail
 Internal implementation details for the µTest++ framework.

Concepts

concept  micro_os_plus::micro_test_plus::detail::free_printable
 Concept satisfied by the types that have a free operator<< for the formatter.
concept  micro_os_plus::micro_test_plus::detail::member_printable
 Concept satisfied by the types that the formatter writes with one of its own member functions operator<<.

Typedefs

using micro_os_plus::micro_test_plus::expression_formatter = detail::expression_formatter
 Public name of the formatter used to report operand values.

Functions

void micro_os_plus::micro_test_plus::detail::append_control_escape (std::string &text, char c)
 Appends the escape sequence of a control character.

Variables

constexpr colours micro_os_plus::micro_test_plus::detail::colours_none {}
 Predefined colour set, without escape sequences.
constexpr colours micro_os_plus::micro_test_plus::detail::colours_red_green
 Predefined colour set, with green for pass and red for fail.

Detailed Description

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.

Definition in file expression-formatter.h.