expression-formatter-inlines.h File
C++ header file with inline implementations for the µTest++ expression formatter. More...
Namespaces Index
Description
C++ header file with inline implementations for the µTest++ expression formatter.
This header provides the inline and template member function implementations for expression_formatter: the constructors, the str() accessor, and the template operators (for the pointers, the value wrappers, the ranges, the scoped enumerations, the pairs, the tuples, the optionals, and the expressions), which are instantiated for each concrete type. It also defines plain_text::append().
The compound expression operators format comparator expressions and wrap them in the pass/fail colour codes of the owning reporter.
Numbers and pointers are formatted with the detail::append_number() and detail::append_pointer() helpers, defined in detail-inlines.h and shared with the reporter.
All definitions reside within the micro_os_plus::micro_test_plus::detail namespace.
This file is included by expression-formatter.h; the applications include micro-os-plus/micro-test-plus.h, not this file.
File Listing
The file content with the documentation metadata removed is:
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 Pointer_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
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.