Skip to main content

expression_formatter Class

Formats values and expressions into an owned string buffer. More...

Declaration

class micro_os_plus::micro_test_plus::detail::expression_formatter { ... }

Included Headers

Public Constructors Index

expression_formatter (colours &colours) noexcept

Constructor with colour configuration. More...

expression_formatter (const expression_formatter &)=delete

Deleted copy constructor to prevent copying. More...

expression_formatter (expression_formatter &&)=delete

Deleted move constructor to prevent moving. More...

Public Destructor Index

~expression_formatter ()=default

Default destructor. More...

Public Operators Index

expression_formatter &operator<< (bool v)

Appends the string representation of a boolean value. More...

expression_formatter &operator<< (char c)

Appends a single character to the buffer. More...

expression_formatter &operator<< (const char *s)

Appends a null-terminated C string to the buffer. More...

template <class Lhs_T, class Rhs_T>
expression_formatter &operator<< (const detail::and_< Lhs_T, Rhs_T > &op)

Formats a logical AND as (lhs and rhs). More...

template <class Lhs_T, class Rhs_T>
expression_formatter &operator<< (const detail::eq_< Lhs_T, Rhs_T > &op)

Formats an equality comparison as lhs == rhs. More...

template <class Lhs_T, class Rhs_T>
expression_formatter &operator<< (const detail::ge_< Lhs_T, Rhs_T > &op)

Formats a greater-than-or-equal comparison as lhs >= rhs. More...

template <class Lhs_T, class Rhs_T>
expression_formatter &operator<< (const detail::gt_< Lhs_T, Rhs_T > &op)

Formats a greater-than comparison as lhs > rhs. More...

template <class Lhs_T, class Rhs_T>
expression_formatter &operator<< (const detail::le_< Rhs_T, Lhs_T > &op)

Formats a less-than-or-equal comparison as lhs <= rhs. More...

template <class Lhs_T, class Rhs_T>
expression_formatter &operator<< (const detail::lt_< Rhs_T, Lhs_T > &op)

Formats a less-than comparison as lhs < rhs. More...

template <class Lhs_T, class Rhs_T>
expression_formatter &operator<< (const detail::ne_< Lhs_T, Rhs_T > &op)

Formats an inequality comparison as lhs != rhs. More...

template <class T>
expression_formatter &operator<< (const detail::not_< T > &op)

Formats a logical NOT as not operand. More...

template <class Callable_T>
expression_formatter &operator<< (const detail::nothrow_< Callable_T > &op)

Formats a nothrow expression as nothrow. More...

template <class Lhs_T, class Rhs_T>
expression_formatter &operator<< (const detail::or_< Lhs_T, Rhs_T > &op)

Formats a logical OR as (lhs or rhs). More...

template <class Callable_T, class Exception_T>
expression_formatter &operator<< (const detail::throws_< Callable_T, Exception_T > &op)

Formats a typed throws expression as throws<TypeName>. More...

template <class Callable_T>
expression_formatter &operator<< (const detail::throws_< Callable_T, void > &op)

Formats an untyped throws expression as throws. More...

template <class T>
expression_formatter &operator<< (const T &t)

Appends a container's elements enclosed in braces. More...

template <class T>
expression_formatter &operator<< (const T &t)

Appends the value of an op expression via detail::get. More...

template <class T>
expression_formatter &operator<< (const type_traits::genuine_integral_value< T > &v)

Appends a genuine integral value without a type suffix. More...

expression_formatter &operator<< (double v)

Appends a double value (no suffix). More...

expression_formatter &operator<< (float v)

Appends a float value with type suffix "f". More...

expression_formatter &operator<< (long double v)

Appends a long double value with type suffix "l". More...

expression_formatter &operator<< (signed char c)

Appends a signed char value with type suffix "c". More...

expression_formatter &operator<< (signed int v)

Appends a signed int value (no suffix). More...

expression_formatter &operator<< (signed long long v)

Appends a signed long long value with type suffix "ll". More...

expression_formatter &operator<< (signed long v)

Appends a signed long value with type suffix "l". More...

expression_formatter &operator<< (signed short v)

Appends a signed short value with type suffix "s". More...

expression_formatter &operator<< (std::nullptr_t)

Appends the string "nullptr". More...

expression_formatter &operator<< (std::string_view sv)

Appends a string view to the buffer. More...

template <typename T>
expression_formatter &operator<< (T *v)

Appends the hexadecimal address of a pointer. More...

expression_formatter &operator<< (unsigned char c)

Appends an unsigned char value with type suffix "uc". More...

expression_formatter &operator<< (unsigned int v)

Appends an unsigned int value with type suffix "u". More...

expression_formatter &operator<< (unsigned long long v)

Appends an unsigned long long value with type suffix "ull". More...

expression_formatter &operator<< (unsigned long v)

Appends an unsigned long value with type suffix "ul". More...

expression_formatter &operator<< (unsigned short v)

Appends an unsigned short value with type suffix "us". More...

expression_formatter &operator= (const expression_formatter &)=delete

Deleted copy assignment operator to prevent copying. More...

expression_formatter &operator= (expression_formatter &&)=delete

Deleted move assignment operator to prevent moving. More...

Public Member Functions Index

voidappend (size_t count, char ch)

Appends a sequence of identical characters to the buffer. More...

const char *c_str () const noexcept

Returns a pointer to the null-terminated buffer contents. More...

voidclear () noexcept

Clears the internal buffer. More...

boolempty () const noexcept

Returns whether the internal buffer is empty. More...

voidreserve (size_t capacity)

Reserves storage in the internal buffer. More...

const std::string &str () const noexcept

Returns a const reference to the internal buffer. More...

Protected Member Functions Index

autocolour_ (const bool cond) const

Selects the appropriate colour code based on a condition. More...

Protected Member Attributes Index

std::stringbuffer_ {}

The internal output buffer. More...

colours &colours_

ANSI colour codes for output formatting. More...

Description

Formats values and expressions into an owned string buffer.

expression_formatter owns a std::string buffer and provides operator<< overloads for all standard arithmetic types, character types, strings, pointers, containers, and framework expression types derived from detail::op.

The numeric overloads append a type suffix (e.g., 42u, 3l, 1.0f) matching the conventions used in the existing reporter output, so that the formatted text is identical whether produced by the reporter directly or pre-formatted by a deferred reporter.

The class is non-copyable and non-movable to avoid accidental copying of the internal buffer.

Definition at line 150 of file expression-formatter.h.

Public Constructors

expression_formatter()

micro_os_plus::micro_test_plus::detail::expression_formatter::expression_formatter (colours & colours)
inline noexcept

Constructor with colour configuration.

Parameters
colours

Reference to a colours instance for output formatting.

Initializes the colours_ reference with the provided colours instance. The internal buffer is default-initialized to an empty string.

Declaration at line 159 of file expression-formatter.h, definition at line 79 of file expression-formatter-inlines.h.

Reference colours_.

Referenced by expression_formatter, expression_formatter, ~expression_formatter, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator= and operator=.

expression_formatter()

micro_os_plus::micro_test_plus::detail::expression_formatter::expression_formatter (const expression_formatter &)
delete

Deleted copy constructor to prevent copying.

Definition at line 164 of file expression-formatter.h.

Reference expression_formatter.

expression_formatter()

micro_os_plus::micro_test_plus::detail::expression_formatter::expression_formatter (expression_formatter &&)
delete

Deleted move constructor to prevent moving.

Definition at line 169 of file expression-formatter.h.

Reference expression_formatter.

Public Destructor

~expression_formatter()

micro_os_plus::micro_test_plus::detail::expression_formatter::~expression_formatter ()
default

Default destructor.

Definition at line 188 of file expression-formatter.h.

Reference expression_formatter.

Public Operators

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (bool v)

Appends the string representation of a boolean value.

Parameters
v

The boolean value.

Returns

Reference to this instance.

Appends the string "true" or "false" to the internal buffer based on the value of v.

Declaration at line 226 of file expression-formatter.h, definition at line 102 of file expression-formatter.cpp.

103 {
104 buffer_.append (v ? "true" : "false");
105 return *this;
106 }

References expression_formatter and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (char c)

Appends a single character to the buffer.

Parameters
c

The character to append.

Returns

Reference to this instance.

Appends the single character c to the internal buffer using buffer_.append(1, c).

Declaration at line 208 of file expression-formatter.h, definition at line 78 of file expression-formatter.cpp.

79 {
80 buffer_.append (1, c);
81 return *this;
82 }

References expression_formatter and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const char * s)

Appends a null-terminated C string to the buffer.

Parameters
s

The C string to append.

Returns

Reference to this instance.

Appends the null-terminated C string s to the internal buffer using buffer_.append(s).

Declaration at line 217 of file expression-formatter.h, definition at line 90 of file expression-formatter.cpp.

91 {
92 buffer_.append (s);
93 return *this;
94 }

References expression_formatter and buffer_.

operator<<()

template <class Lhs_T, class Rhs_T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const detail::and_< Lhs_T, Rhs_T > & op)

Formats a logical AND as (lhs and rhs).

Template Parameters
Lhs_T

Left-hand operand type.

Rhs_T

Right-hand operand type.

Parameters
op

The logical AND expression.

Returns

Reference to this instance.

This operator overload enables the reporter to output logical conjunction (AND) expressions in a clear and structured format.

The left-hand side and right-hand side expressions are enclosed in parentheses and separated by the word "and", with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This presentation assists in quickly identifying the components of logical assertions and facilitates efficient debugging of test failures involving compound conditions.

Declaration at line 496 of file expression-formatter.h, definition at line 395 of file expression-formatter-inlines.h.

396 {
397 return (*this << '(' << op.lhs () << colour_ (op) << " and "
398 << colours_.none << op.rhs () << ')');
399 }

References expression_formatter, colour_, colours_, micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::lhs and micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::rhs.

operator<<()

template <class Lhs_T, class Rhs_T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const detail::eq_< Lhs_T, Rhs_T > & op)

Formats an equality comparison as lhs == rhs.

Template Parameters
Lhs_T

Left-hand operand type.

Rhs_T

Right-hand operand type.

Parameters
op

The equality expression.

Returns

Reference to this instance.

This operator overload enables the reporter to output equality comparison expressions in a clear and expressive format.

The left-hand side and right-hand side values are formatted and separated by the equality operator (==), with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This structured output assists in quickly identifying the values involved in equality assertions and facilitates efficient debugging of test failures.

Declaration at line 424 of file expression-formatter.h, definition at line 274 of file expression-formatter-inlines.h.

275 {
276 return (*this << colour_ (op) << op.lhs () << " == " << op.rhs ()
277 << colours_.none);
278 }

References expression_formatter, colour_, colours_, micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::lhs and micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::rhs.

operator<<()

template <class Lhs_T, class Rhs_T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const detail::ge_< Lhs_T, Rhs_T > & op)

Formats a greater-than-or-equal comparison as lhs >= rhs.

Template Parameters
Lhs_T

Left-hand operand type.

Rhs_T

Right-hand operand type.

Parameters
op

The greater-than-or-equal expression.

Returns

Reference to this instance.

This operator overload enables the reporter to output greater-than-or-equal-to comparison expressions in a clear and expressive format.

The left-hand side and right-hand side values are formatted and separated by the greater-than-or-equal-to operator (>=), with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This structured output assists in quickly identifying the values involved in greater-than-or-equal-to assertions and facilitates efficient debugging of test failures.

Declaration at line 460 of file expression-formatter.h, definition at line 335 of file expression-formatter-inlines.h.

336 {
337 return (*this << colour_ (op) << op.lhs () << " >= " << op.rhs ()
338 << colours_.none);
339 }

References expression_formatter, colour_, colours_, micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::lhs and micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::rhs.

operator<<()

template <class Lhs_T, class Rhs_T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const detail::gt_< Lhs_T, Rhs_T > & op)

Formats a greater-than comparison as lhs > rhs.

Template Parameters
Lhs_T

Left-hand operand type.

Rhs_T

Right-hand operand type.

Parameters
op

The greater-than expression.

Returns

Reference to this instance.

This operator overload enables the reporter to output greater-than comparison expressions in a clear and expressive format.

The left-hand side and right-hand side values are formatted and separated by the greater-than operator (>), with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This structured output assists in quickly identifying the values involved in greater-than assertions and facilitates efficient debugging of test failures.

Declaration at line 448 of file expression-formatter.h, definition at line 314 of file expression-formatter-inlines.h.

315 {
316 return (*this << colour_ (op) << op.lhs () << " > " << op.rhs ()
317 << colours_.none);
318 }

References expression_formatter, colour_, colours_, micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::lhs and micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::rhs.

operator<<()

template <class Lhs_T, class Rhs_T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const detail::le_< Rhs_T, Lhs_T > & op)

Formats a less-than-or-equal comparison as lhs <= rhs.

Template Parameters
Lhs_T

Left-hand operand type.

Rhs_T

Right-hand operand type.

Parameters
op

The less-than-or-equal expression.

Returns

Reference to this instance.

This operator overload enables the reporter to output less-than-or-equal-to comparison expressions in a clear and expressive format.

The left-hand side and right-hand side values are formatted and separated by the less-than-or-equal-to operator (<=), with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This structured output assists in quickly identifying the values involved in less-than-or-equal-to assertions and facilitates efficient debugging of test failures.

Declaration at line 484 of file expression-formatter.h, definition at line 375 of file expression-formatter-inlines.h.

376 {
377 return (*this << colour_ (op) << op.lhs () << " <= " << op.rhs ()
378 << colours_.none);
379 }

References expression_formatter, colour_, colours_, micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::lhs and micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::rhs.

operator<<()

template <class Lhs_T, class Rhs_T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const detail::lt_< Rhs_T, Lhs_T > & op)

Formats a less-than comparison as lhs < rhs.

Template Parameters
Lhs_T

Left-hand operand type.

Rhs_T

Right-hand operand type.

Parameters
op

The less-than expression.

Returns

Reference to this instance.

This operator overload enables the reporter to output less-than comparison expressions in a clear and expressive format.

The left-hand side and right-hand side values are formatted and separated by the less-than operator (<), with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This structured output assists in quickly identifying the values involved in less-than assertions and facilitates efficient debugging of test failures.

Declaration at line 472 of file expression-formatter.h, definition at line 354 of file expression-formatter-inlines.h.

355 {
356 return (*this << colour_ (op) << op.lhs () << " < " << op.rhs ()
357 << colours_.none);
358 }

References expression_formatter, colour_, colours_, micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::lhs and micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::rhs.

operator<<()

template <class Lhs_T, class Rhs_T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const detail::ne_< Lhs_T, Rhs_T > & op)

Formats an inequality comparison as lhs != rhs.

Template Parameters
Lhs_T

Left-hand operand type.

Rhs_T

Right-hand operand type.

Parameters
op

The inequality expression.

Returns

Reference to this instance.

This operator overload enables the reporter to output inequality comparison expressions in a clear and expressive format.

The left-hand side and right-hand side values are formatted and separated by the inequality operator (!=), with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This structured output assists in quickly identifying the values involved in inequality assertions and facilitates efficient debugging of test failures.

Declaration at line 436 of file expression-formatter.h, definition at line 294 of file expression-formatter-inlines.h.

295 {
296 return (*this << colour_ (op) << op.lhs () << " != " << op.rhs ()
297 << colours_.none);
298 }

References expression_formatter, colour_, colours_, micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::lhs and micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::rhs.

operator<<()

template <class T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const detail::not_< T > & op)

Formats a logical NOT as not operand.

Template Parameters
T

The operand type.

Parameters
op

The logical NOT expression.

Returns

Reference to this instance.

This operator overload enhances readability and clarity by formatting the output when handling negated expressions. It applies colour styling for improved distinction and appends the negated value accordingly, ensuring that logical negations are clearly represented in test reports and diagnostics.

Declaration at line 519 of file expression-formatter.h, definition at line 431 of file expression-formatter-inlines.h.

432 {
433 return (*this << colour_ (op) << "not " << op.operand () << colours_.none);
434 }

References expression_formatter, colour_, colours_ and micro_os_plus::micro_test_plus::detail::unary_op_< T >::operand.

operator<<()

template <class Callable_T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const detail::nothrow_< Callable_T > & op)

Formats a nothrow expression as nothrow.

Template Parameters
Callable_T

The callable type.

Parameters
op

The nothrow expression.

Returns

Reference to this instance.

This operator overload formats output for expressions that do not throw exceptions. It applies colour styling for clarity and ensures a structured and concise representation of exception safety within test reports.

The output highlights the nothrow qualifier, making it immediately apparent when an expression is guaranteed not to throw, thereby improving the readability and professionalism of the test output.

Declaration at line 555 of file expression-formatter.h, definition at line 489 of file expression-formatter-inlines.h.

490 {
491 return (*this << colour_ (op) << "nothrow" << colours_.none);
492 }

References expression_formatter, colour_ and colours_.

operator<<()

template <class Lhs_T, class Rhs_T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const detail::or_< Lhs_T, Rhs_T > & op)

Formats a logical OR as (lhs or rhs).

Template Parameters
Lhs_T

Left-hand operand type.

Rhs_T

Right-hand operand type.

Parameters
op

The logical OR expression.

Returns

Reference to this instance.

This operator overload enables the reporter to output logical disjunction (OR) expressions in a clear and structured format.

The left-hand side and right-hand side expressions are enclosed in parentheses and separated by the word "or", with appropriate colour highlighting applied for improved readability in test reports and diagnostics. This presentation assists in quickly identifying the components of logical assertions and facilitates efficient debugging of test failures involving compound conditions.

Declaration at line 508 of file expression-formatter.h, definition at line 415 of file expression-formatter-inlines.h.

416 {
417 return (*this << '(' << op.lhs () << colour_ (op) << " or "
418 << colours_.none << op.rhs () << ')');
419 }

References expression_formatter, colour_, colours_, micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::lhs and micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::rhs.

operator<<()

template <class Callable_T, class Exception_T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const detail::throws_< Callable_T, Exception_T > & op)

Formats a typed throws expression as throws<TypeName>.

Template Parameters
Callable_T

The callable type.

Exception_T

The expected exception type.

Parameters
op

The throws expression.

Returns

Reference to this instance.

This operator overload provides structured output for expressions that may throw exceptions. It applies colour styling for clarity and includes the exception type name for precise identification.

When invoked, the output highlights the throws qualifier along with the specific exception type, making it immediately apparent which exception is expected. This enhances the readability and professionalism of test reports, and assists in the precise identification and debugging of exception-related test cases.

Declaration at line 533 of file expression-formatter.h, definition at line 451 of file expression-formatter-inlines.h.

453 {
454 return (*this << colour_ (op) << "throws<"
456 << colours_.none);
457 }

References expression_formatter, colour_, colours_ and micro_os_plus::micro_test_plus::reflection::type_name.

operator<<()

template <class Callable_T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const detail::throws_< Callable_T, void > & op)

Formats an untyped throws expression as throws.

Template Parameters
Callable_T

The callable type.

Parameters
op

The throws expression.

Returns

Reference to this instance.

This operator overload formats output for expressions that may throw exceptions. It applies colour styling for clarity and ensures a structured representation of the exception handling mechanism.

When invoked, the output highlights the throws qualifier, making it immediately apparent when an expression is expected to throw, thereby improving the readability and professionalism of the test output.

Declaration at line 544 of file expression-formatter.h, definition at line 471 of file expression-formatter-inlines.h.

473 {
474 return (*this << colour_ (op) << "throws" << colours_.none);
475 }

References expression_formatter, colour_ and colours_.

operator<<()

template <class T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const T & t)

Appends a container's elements enclosed in braces.

Elements are formatted as { e1, e2, … } by iterating the container and recursing through operator<< for each element.

Template Parameters
T

A container type satisfying type_traits::container_like that does not have npos.

Parameters
t

The container.

Returns

Reference to this instance.

Definition at line 409 of file expression-formatter.h.

References expression_formatter, append, c_str, clear, colour_, empty and reserve.

operator<<()

template <class T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const T & t)

Appends the value of an op expression via detail::get.

Template Parameters
T

An expression type satisfying type_traits::is_op<T>.

Parameters
t

The expression object.

Returns

Reference to this instance.

Delegates to detail::get(t) to obtain the displayable value of an op expression, then streams it through operator<< to format it into the buffer.

Iterates the container and formats each element separated by ", ", surrounded by { and }. Each element is streamed through operator<<, which recurses as needed for nested types.

Declaration at line 380 of file expression-formatter.h, definition at line 216 of file expression-formatter-inlines.h.

217 {
218 *this << detail::get (t);
219 return *this;
220 }

References expression_formatter and micro_os_plus::micro_test_plus::detail::get.

operator<<()

template <class T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (const type_traits::genuine_integral_value< T > & v)

Appends a genuine integral value without a type suffix.

Template Parameters
T

The underlying integral type.

Parameters
v

The strongly-typed integral value.

Returns

Reference to this instance.

Casts the underlying integral value to long long and formats it without a type suffix, appending the result to the buffer.

Declaration at line 391 of file expression-formatter.h, definition at line 229 of file expression-formatter-inlines.h.

231 {
232 detail::append_number_ (buffer_, static_cast<long long> (v.get ()));
233 return *this;
234 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_, buffer_ and micro_os_plus::micro_test_plus::type_traits::value_base_< T >::get.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (double v)

Appends a double value (no suffix).

Parameters
v

The double value.

Returns

Reference to this instance.

Converts v to its string representation via append_number_() without a type suffix.

Declaration at line 341 of file expression-formatter.h, definition at line 267 of file expression-formatter.cpp.

268 {
270 return *this;
271 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (float v)

Appends a float value with type suffix "f".

Parameters
v

The float value.

Returns

Reference to this instance.

Converts v to its string representation via append_number_() and appends the type suffix "f".

Declaration at line 332 of file expression-formatter.h, definition at line 254 of file expression-formatter.cpp.

255 {
257 buffer_.append ("f");
258 return *this;
259 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (long double v)

Appends a long double value with type suffix "l".

Parameters
v

The long double value.

Returns

Reference to this instance.

Converts v to its string representation via append_number_() and appends the type suffix "l".

Declaration at line 350 of file expression-formatter.h, definition at line 279 of file expression-formatter.cpp.

280 {
282 buffer_.append ("l");
283 return *this;
284 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (signed char c)

Appends a signed char value with type suffix "c".

Parameters
c

The signed char value.

Returns

Reference to this instance.

Converts c to its decimal string representation via append_number_() and appends the type suffix "c".

Declaration at line 242 of file expression-formatter.h, definition at line 125 of file expression-formatter.cpp.

126 {
128 buffer_.append ("c");
129 return *this;
130 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (signed int v)

Appends a signed int value (no suffix).

Parameters
v

The signed int value.

Returns

Reference to this instance.

Converts v to its decimal string representation via append_number_() without a type suffix.

Declaration at line 278 of file expression-formatter.h, definition at line 177 of file expression-formatter.cpp.

178 {
180 return *this;
181 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (signed long long v)

Appends a signed long long value with type suffix "ll".

Parameters
v

The signed long long value.

Returns

Reference to this instance.

Converts v to its decimal string representation via append_number_() and appends the type suffix "ll".

Declaration at line 314 of file expression-formatter.h, definition at line 228 of file expression-formatter.cpp.

228 expression_formatter::operator<<(signed long long v)
229 {
231 buffer_.append ("ll");
232 return *this;
233 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (signed long v)

Appends a signed long value with type suffix "l".

Parameters
v

The signed long value.

Returns

Reference to this instance.

Converts v to its decimal string representation via append_number_() and appends the type suffix "l".

Declaration at line 296 of file expression-formatter.h, definition at line 202 of file expression-formatter.cpp.

203 {
205 buffer_.append ("l");
206 return *this;
207 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (signed short v)

Appends a signed short value with type suffix "s".

Parameters
v

The signed short value.

Returns

Reference to this instance.

Converts v to its decimal string representation via append_number_() and appends the type suffix "s".

Declaration at line 260 of file expression-formatter.h, definition at line 151 of file expression-formatter.cpp.

152 {
154 buffer_.append ("s");
155 return *this;
156 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (std::nullptr_t)

Appends the string "nullptr".

Returns

Reference to this instance.

Appends the string "nullptr" to the internal buffer.

Declaration at line 234 of file expression-formatter.h, definition at line 113 of file expression-formatter.cpp.

114 {
115 buffer_.append ("nullptr");
116 return *this;
117 }

References expression_formatter and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (std::string_view sv)

Appends a string view to the buffer.

Parameters
sv

The string view to append.

Returns

Reference to this instance.

Appends the contents of the std::string_view directly to the internal buffer using buffer_.append(sv).

Declaration at line 199 of file expression-formatter.h, definition at line 66 of file expression-formatter.cpp.

66 expression_formatter::operator<<(std::string_view sv)
67 {
68 buffer_.append (sv);
69 return *this;
70 }

References expression_formatter and buffer_.

operator<<()

template <typename T>
expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (T * v)

Appends the hexadecimal address of a pointer.

Null pointers are rendered as "0x0". Non-null pointers are formatted with snprintf using the p specifier.

Template Parameters
T

The type pointed to.

Parameters
v

The pointer value.

Returns

Reference to this instance.

Null pointers are rendered as "0x0" to avoid platform-specific representations such as "(nil)" on Linux/glibc. Non-null pointers are formatted as a hexadecimal address using snprintf with the p specifier.

Declaration at line 368 of file expression-formatter.h, definition at line 185 of file expression-formatter-inlines.h.

186 {
187 if (v == nullptr)
188 {
189 buffer_.append ("0x0");
190 return *this;
191 }
192#if defined(__GNUC__)
193#pragma GCC diagnostic push
194#if defined(__clang__)
195#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
196#endif
197#endif
198 char buff[20];
199 snprintf (buff, sizeof (buff), "%p", reinterpret_cast<void*> (v));
200 buffer_.append (buff);
201#if defined(__GNUC__)
202#pragma GCC diagnostic pop
203#endif
204 return *this;
205 }

References expression_formatter and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (unsigned char c)

Appends an unsigned char value with type suffix "uc".

Parameters
c

The unsigned char value.

Returns

Reference to this instance.

Converts c to its decimal string representation via append_number_() and appends the type suffix "uc".

Declaration at line 251 of file expression-formatter.h, definition at line 138 of file expression-formatter.cpp.

139 {
141 buffer_.append ("uc");
142 return *this;
143 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (unsigned int v)

Appends an unsigned int value with type suffix "u".

Parameters
v

The unsigned int value.

Returns

Reference to this instance.

Converts v to its decimal string representation via append_number_() and appends the type suffix "u".

Declaration at line 287 of file expression-formatter.h, definition at line 189 of file expression-formatter.cpp.

190 {
192 buffer_.append ("u");
193 return *this;
194 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (unsigned long long v)

Appends an unsigned long long value with type suffix "ull".

Parameters
v

The unsigned long long value.

Returns

Reference to this instance.

Converts v to its decimal string representation via append_number_() and appends the type suffix "ull".

Declaration at line 323 of file expression-formatter.h, definition at line 241 of file expression-formatter.cpp.

241 expression_formatter::operator<<(unsigned long long v)
242 {
244 buffer_.append ("ull");
245 return *this;
246 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (unsigned long v)

Appends an unsigned long value with type suffix "ul".

Parameters
v

The unsigned long value.

Returns

Reference to this instance.

Converts v to its decimal string representation via append_number_() and appends the type suffix "ul".

Declaration at line 305 of file expression-formatter.h, definition at line 215 of file expression-formatter.cpp.

216 {
218 buffer_.append ("ul");
219 return *this;
220 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator<<()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< (unsigned short v)

Appends an unsigned short value with type suffix "us".

Parameters
v

The unsigned short value.

Returns

Reference to this instance.

Converts v to its decimal string representation via append_number_() and appends the type suffix "us".

Declaration at line 269 of file expression-formatter.h, definition at line 164 of file expression-formatter.cpp.

164 expression_formatter::operator<<(unsigned short v)
165 {
167 buffer_.append ("us");
168 return *this;
169 }

References expression_formatter, micro_os_plus::micro_test_plus::detail::append_number_ and buffer_.

operator=()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator= (const expression_formatter &)
delete

Deleted copy assignment operator to prevent copying.

Definition at line 175 of file expression-formatter.h.

Reference expression_formatter.

operator=()

expression_formatter & micro_os_plus::micro_test_plus::detail::expression_formatter::operator= (expression_formatter &&)
delete

Deleted move assignment operator to prevent moving.

Definition at line 182 of file expression-formatter.h.

Reference expression_formatter.

Public Member Functions

append()

void micro_os_plus::micro_test_plus::detail::expression_formatter::append (size_t count, char ch)
inline

Appends a sequence of identical characters to the buffer.

Parameters
count

The number of characters to append.

ch

The character to repeat.

Returns

Nothing.

Appends count repetitions of ch to the internal buffer by delegating to buffer_.append(count, ch).

Declaration at line 613 of file expression-formatter.h, definition at line 148 of file expression-formatter-inlines.h.

148 expression_formatter::append (size_t count, char ch)
149 {
150 buffer_.append (count, ch);
151 }

Reference buffer_.

Referenced by operator<<.

c_str()

const char * micro_os_plus::micro_test_plus::detail::expression_formatter::c_str ()
inline nodiscard noexcept

Returns a pointer to the null-terminated buffer contents.

Parameters

None.

Returns

Pointer to the null-terminated character array.

Returns buffer_.c_str(), providing a pointer to the null-terminated contents of the internal buffer.

Declaration at line 580 of file expression-formatter.h, definition at line 115 of file expression-formatter-inlines.h.

116 {
117 return buffer_.c_str ();
118 }

Reference buffer_.

Referenced by operator<<.

clear()

void micro_os_plus::micro_test_plus::detail::expression_formatter::clear ()
inline noexcept

Clears the internal buffer.

Parameters

None.

Returns

Nothing.

Calls buffer_.clear(), resetting the buffer length to zero without releasing the allocated storage.

Declaration at line 591 of file expression-formatter.h, definition at line 126 of file expression-formatter-inlines.h.

127 {
128 buffer_.clear ();
129 }

Reference buffer_.

Referenced by micro_os_plus::micro_test_plus::detail::deferred_reporter::deferred_reporter and operator<<.

empty()

bool micro_os_plus::micro_test_plus::detail::expression_formatter::empty ()
inline nodiscard noexcept

Returns whether the internal buffer is empty.

Parameters

None.

Return Values
true

The buffer contains no characters.

false

The buffer contains at least one character.

Returns buffer_.empty(), indicating whether the accumulated string has zero length.

Declaration at line 602 of file expression-formatter.h, definition at line 137 of file expression-formatter-inlines.h.

138 {
139 return buffer_.empty ();
140 }

Reference buffer_.

Referenced by operator<<.

reserve()

void micro_os_plus::micro_test_plus::detail::expression_formatter::reserve (size_t capacity)
inline

Reserves storage in the internal buffer.

Parameters
capacity

The minimum capacity to reserve.

Returns

Nothing.

Calls buffer_.reserve(capacity) to pre-allocate storage, reducing subsequent dynamic allocations.

Declaration at line 623 of file expression-formatter.h, definition at line 159 of file expression-formatter-inlines.h.

160 {
161 buffer_.reserve (capacity);
162 }

Reference buffer_.

Referenced by operator<<.

str()

const std::string & micro_os_plus::micro_test_plus::detail::expression_formatter::str ()
inline nodiscard noexcept

Returns a const reference to the internal buffer.

Parameters

None.

Returns

Const reference to the accumulated string.

Returns a const reference to the internal buffer_ string.

Declaration at line 570 of file expression-formatter.h, definition at line 104 of file expression-formatter-inlines.h.

104 expression_formatter::str () const noexcept
105 {
106 return buffer_;
107 }

Reference buffer_.

Protected Member Functions

colour_()

auto micro_os_plus::micro_test_plus::detail::expression_formatter::colour_ (const bool cond)
inline nodiscard protected

Selects the appropriate colour code based on a condition.

Parameters
cond

Boolean value indicating pass (true) or fail (false).

Returns

The corresponding ANSI colour code as a string.

Returns the ANSI colour code for pass or fail, depending on the boolean condition provided.

Declaration at line 633 of file expression-formatter.h, definition at line 92 of file expression-formatter-inlines.h.

92 expression_formatter::colour_ (const bool cond) const
93 {
94 return cond ? colours_.pass : colours_.fail;
95 }

Reference colours_.

Referenced by operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<<, operator<< and operator<<.

Protected Member Attributes

buffer_

std::string micro_os_plus::micro_test_plus::detail::expression_formatter::buffer_ {}
protected

colours_

colours& micro_os_plus::micro_test_plus::detail::expression_formatter::colours_
protected

The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.