49#pragma GCC diagnostic ignored "-Waggregate-return"
51#pragma clang diagnostic ignored "-Wc++98-compat"
52#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
53#pragma clang diagnostic ignored "-Wexit-time-destructors"
59#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_ENABLED)
99 append_hex (std::string& buffer,
char32_t code, std::string_view escape,
102 constexpr std::string_view digits{
"0123456789abcdef" };
103 buffer.append (escape);
104 for (std::size_t i = count; i > 0; --i)
108 const auto nibble = (code >> ((i - 1) * 4)) & 0x0Fu;
109 buffer.push_back (digits[nibble]);
132 buffer.push_back (
'"');
133 for (
const char c : sv)
138 buffer.append (
"\\0");
141 buffer.append (
"\\a");
144 buffer.append (
"\\b");
147 buffer.append (
"\\t");
150 buffer.append (
"\\n");
153 buffer.append (
"\\v");
156 buffer.append (
"\\f");
159 buffer.append (
"\\r");
162 buffer.append (
"\\\"");
165 buffer.append (
"\\\\");
168 if (
static_cast<unsigned char> (c) < 0x20 || c == 0x7F)
170 append_hex (buffer,
static_cast<unsigned char> (c),
"\\x",
175 buffer.push_back (c);
180 buffer.push_back (
'"');
196 if ((code >= 0xD800 && code <= 0xDFFF) || code > 0x10FFFF)
203 text.push_back (
static_cast<char> (code));
205 else if (code < 0x800)
207 text.push_back (
static_cast<char> (0xC0 | (code >> 6)));
208 text.push_back (
static_cast<char> (0x80 | (code & 0x3F)));
210 else if (code < 0x10000)
212 text.push_back (
static_cast<char> (0xE0 | (code >> 12)));
213 text.push_back (
static_cast<char> (0x80 | ((code >> 6) & 0x3F)));
214 text.push_back (
static_cast<char> (0x80 | (code & 0x3F)));
218 text.push_back (
static_cast<char> (0xF0 | (code >> 18)));
219 text.push_back (
static_cast<char> (0x80 | ((code >> 12) & 0x3F)));
220 text.push_back (
static_cast<char> (0x80 | ((code >> 6) & 0x3F)));
221 text.push_back (
static_cast<char> (0x80 | (code & 0x3F)));
238 template <
class Char_T>
243 text.reserve (sv.size ());
244 for (std::size_t i = 0; i < sv.size (); ++i)
246 const auto unit =
static_cast<char32_t> (sv[i]) & 0xFFFFu;
247 if (unit >= 0xD800 && unit <= 0xDBFF && i + 1 < sv.size ())
249 const auto next =
static_cast<char32_t> (sv[i + 1]) & 0xFFFFu;
250 if (next >= 0xDC00 && next <= 0xDFFF)
252 append_utf8 (text, 0x10000 + ((unit - 0xD800) << 10)
277 template <
class Char_T>
282 text.reserve (sv.size ());
283 for (
const Char_T unit : sv)
305 const auto unit =
static_cast<unsigned char> (c);
306 return (unit < 0x20 && c !=
'\t' && c !=
'\n') || unit == 0x7F;
324 for (
const char c : sv)
332 buffer.push_back (c);
354 template <
class Char_T>
355 std::basic_string_view<Char_T>
358 if (capacity == std::basic_string_view<Char_T>::npos)
360 return std::basic_string_view<Char_T>{ s };
363 const std::basic_string_view<Char_T> buffer{ s, capacity };
364 return buffer.substr (0, buffer.find (Char_T{}));
383 template <
class Char_T>
389 buffer.append (text);
430 append_hex (text,
static_cast<unsigned char> (c),
"\\x", 2);
469 if constexpr (
sizeof (wchar_t) == 2)
471 return *
this << std::string_view{ utf16_to_utf8 (sv) };
475 return *
this << std::string_view{ utf32_to_utf8 (sv) };
479#if defined(__cpp_lib_char8_t)
488 return *
this << std::string_view{
489 reinterpret_cast<const char*
> (sv.data ()), sv.size ()
501 return *
this << std::string_view{ utf16_to_utf8 (sv) };
511 return *
this << std::string_view{ utf32_to_utf8 (sv) };
533 if (is_escaped_in_plain (c))
548#if defined(__cpp_char8_t)
620 append_plain (
buffer_, bounded_view (s, capacity));
631 std::size_t capacity)
638 append_wide_text (
buffer_, bounded_view (s, capacity));
641#if defined(__cpp_lib_char8_t)
648 std::size_t capacity)
655 append_wide_text (
buffer_, bounded_view (s, capacity));
665 std::size_t capacity)
672 append_wide_text (
buffer_, bounded_view (s, capacity));
681 std::size_t capacity)
688 append_wide_text (
buffer_, bounded_view (s, capacity));
691#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
713 buffer_.append (v ?
"true" :
"false");
750 const auto start =
buffer_.size ();
765 const auto start =
buffer_.size ();
781 const auto start =
buffer_.size ();
797 const auto start =
buffer_.size ();
890 const auto start =
buffer_.size ();
893 if (std::isfinite (v))
909 const auto start =
buffer_.size ();
928 const auto start =
buffer_.size ();
931 if (std::isfinite (v))
964 for (
auto i = start; i <
buffer_.size (); ++i)
1016 char32_t code, std::size_t size)
1053 if (code < 0x20 || code == 0x7F)
1055 append_hex (
buffer_, code,
"\\x", 2);
1057 else if (code < 0x7F)
1059 buffer_.push_back (
static_cast<char> (code));
1061 else if (size == 1 || (code >= 0xD800 && code <= 0xDFFF)
1064 append_hex (
buffer_, code,
"\\x", size * 2);
1066 else if (code <= 0xFFFF)
1068 append_hex (
buffer_, code,
"\\u", 4);
1072 append_hex (
buffer_, code,
"\\U", 8);
1114 for (
size_t i = 0; i <
pending_.size (); ++i)
1122 static const std::string
empty{};
1144 for (
size_t i = 0; i <
pending_.size (); ++i)
C++ header file with declarations for the deprecated µTest++ definitions.
Internal implementation details for the µTest++ framework.
void append_control_escape(std::string &text, char c)
Appends the escape sequence of a control character.
void append_number(std::string &buffer, T v)
Appends the shortest decimal representation of a numeric value to a buffer.
Struct representing a named boolean constant, created by the _b literal.
constexpr std::string_view name(void) const noexcept
Returns the name of the constant.
static void append(std::string &text, const T &value)
Appends a value to a text, in the plain mode of the formatter.