45#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_EXPRESSION_FORMATTER_INLINES_H_
46#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_EXPRESSION_FORMATTER_INLINES_H_
50#if defined(__cplusplus)
59#pragma GCC diagnostic push
61#pragma GCC diagnostic ignored "-Waggregate-return"
63#pragma clang diagnostic ignored "-Wunknown-warning-option"
64#pragma clang diagnostic ignored "-Wc++98-compat"
65#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
102 std::string&& buffer) noexcept
148 inline const std::string&
154#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
186 template <
typename Po
inter_T>
200 template <
typename Char_T, std::
size_t N>
203 expression_formatter::operator<< (
const Char_T (&s)[N])
214 template <
typename T>
217 expression_formatter::operator<< (T* v)
223#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
235 expression_formatter::operator<< (
const T& t)
267 for (
const auto& arg : t)
271 *
this << (count == 0 ?
"" :
", ");
272 using element_type = std::remove_cvref_t<
decltype (arg)>;
273 if constexpr (std::is_same_v<element_type, signed char>
274 or std::is_same_v<element_type, unsigned char>)
276 *this << static_cast<int> (arg);
289 *
this <<
" elements)";
302 requires (std::is_enum_v<T>
303 and not std::is_convertible_v<T, std::underlying_type_t<T>>)
305 expression_formatter::operator<< (T v)
307 return *this << static_cast<std::underlying_type_t<T>> (v);
315 template <
class T1,
class T2>
318 expression_formatter::operator<< (
const std::pair<T1, T2>& p)
331 template <
class... Ts>
357 return *
this << std::nullopt;
368 template <
class Rep,
class Period>
369 requires std::is_arithmetic_v<Rep>
372 const std::chrono::duration<Rep, Period>& d)
376 if constexpr (std::is_same_v<Period, std::nano>)
378 return *
this <<
"ns";
380 else if constexpr (std::is_same_v<Period, std::micro>)
382 return *
this <<
"us";
384 else if constexpr (std::is_same_v<Period, std::milli>)
386 return *
this <<
"ms";
388 else if constexpr (std::is_same_v<Period, std::ratio<1>>)
392 else if constexpr (std::is_same_v<Period, std::ratio<60>>)
394 return *
this <<
"min";
396 else if constexpr (std::is_same_v<Period, std::ratio<3600>>)
406 return *
this <<
"]s";
416 template <
class Tuple_T, std::size_t... Is>
419 std::index_sequence<Is...>)
421 ((*
this << (Is == 0 ?
"" :
", "),
append_value (std::get<Is> (t))), ...);
434 template <
character Char_T>
463 using pointee_type = std::remove_cv_t<std::remove_pointer_t<T>>;
466 *this << detail::basic_c_string<pointee_type>{
value };
516 template <
class Lhs_T,
class Rhs_T,
class Compare_T>
527 *
this << Compare_T::symbol;
530 using lhs_type = std::remove_cvref_t<
decltype (
op.lhs ())>;
531 using rhs_type = std::remove_cvref_t<
decltype (
op.rhs ())>;
532 if constexpr (std::is_same_v<Compare_T, detail::equal_to>
535 and
requires (
const lhs_type& l,
const rhs_type& r) {
537 *std::begin (l) == *std::begin (r)
538 } -> std::convertible_to<bool>;
553 template <
class Lhs_T,
class Rhs_T>
558 auto l = std::begin (lhs);
559 const auto l_end = std::end (lhs);
560 auto r = std::begin (rhs);
561 const auto r_end = std::end (rhs);
576 *
this <<
" (first difference at index ";
587 template <
class Lhs_T,
class Rhs_T,
class Epsilon_T>
592 return (*
this <<
colour (
op) <<
op.lhs () <<
" ~ (" <<
op.rhs () <<
" +/- "
603 template <
class Lhs_T,
class Rhs_T>
609 return (*
this <<
")");
629 template <
class Lhs_T,
class Rhs_T>
646 template <
class Lhs_T,
class Rhs_T>
652 return (*
this <<
")");
672 template <
class Lhs_T,
class Rhs_T>
693 *
this << not_colour <<
"not ";
717 template <
class Lhs_T,
class Rhs_T,
class Compare_T>
723 *
this <<
"(" <<
op << outer_colour <<
")";
732 template <
class Lhs_T,
class Rhs_T,
class Epsilon_T>
738 *
this <<
"(" <<
op << outer_colour <<
")";
747 template <
class T,
class Predicate_T>
755 *
this << Predicate_T::symbol;
761#if defined(__cpp_exceptions)
768 template <
class Exception_T>
772 if constexpr (std::is_void_v<Exception_T>)
812 if (
static_cast<bool> (
op))
819 buffer_.append (
", but a std::exception was thrown: ");
820 *
this << std::string_view{
op.what () };
824 buffer_.append (
", but an exception of unknown type was thrown");
828 buffer_.append (
", but nothing was thrown");
848 text = std::move (formatter.
buffer_);
855#pragma GCC diagnostic pop
Concept satisfied by the pointers to the character types.
Concept satisfied by the character types.
Concept satisfied by the types that have a free operator<< for the formatter.
Concept satisfied by the types that the formatter writes with one of its own member functions operato...
Concept satisfied when the tag of a comparator or of a predicate has a symbol that can be written.
Concept satisfied when a type is a framework expression type.
Concept satisfied when a type can be appended to the message of a check result via operator<<.
Internal implementation details for the µTest++ framework.
void append_number(std::string &buffer, T v)
Appends the shortest decimal representation of a numeric value to a buffer.
constexpr colours colours_none
Predefined colour set, without escape sequences.
decltype(auto) constexpr unwrap(const T &t)
Returns the value wrapped by a framework type, or the operand itself.
void append_pointer(std::string &buffer, T *v)
Appends the hexadecimal address of a pointer to a buffer.
@ std_exception
A std::exception that was not the expected one was thrown; its what() is kept.
@ unknown_exception
Another exception was thrown.
constexpr auto type_name(void) -> std::string_view
Extracts the type name from the __PRETTY_FUNCTION__ identifier.
C++ header file with declarations for the µTest++ reflection utilities.
Logical AND comparator struct template.
Approximate comparator struct template.
A C string operand of a comparator.
constexpr bool is_null(void) const noexcept
Returns whether the operand is a null pointer.
constexpr std::basic_string_view< Char_T > view(void) const noexcept
Returns the characters, as a string view.
Common base struct for callable-wrapping operators.
Colours used to highlight pass and fail results in test reports.
const char * none
Terminal colour reset sequence.
const char * fail
Terminal colour sequence for failing tests.
const char * pass
Terminal colour sequence for passing tests.
Relational comparator struct template.
static constexpr bool apply(const Lhs_T &lhs, const Rhs_T &rhs)
Compares the operands with ==.
Logical NOT comparator struct template.
Operator struct to check if an expression does not throw any exception.
Empty base struct for the framework expression types.
Logical OR comparator struct template.
static void append(std::string &text, const T &value)
Appends a value to a text, in the plain mode of the formatter.
Unary predicate struct template.
Operator struct template to check if an expression throws a specific exception.
Struct template representing a generic value, accessible via a getter.