From 69e14c9f3a9fe35a80a22f121969cef914ede063 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 6 Jan 2022 15:30:02 +0100 Subject: Adjustments for msbuild --- src/test-helper.cpp | 25 +++++++++++++++++++++++++ src/test-helper.h | 6 ++++++ 2 files changed, 31 insertions(+) (limited to 'src') diff --git a/src/test-helper.cpp b/src/test-helper.cpp index d441895..d591916 100644 --- a/src/test-helper.cpp +++ b/src/test-helper.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include #include #include @@ -50,6 +52,29 @@ namespace std { return os; } +#ifdef __cpp_char8_t + std::ostream& operator<<(std::ostream& os, utf8_t const& c) + { + os << "\\x" << std::setfill('0') << std::setw(2) << std::right << std::hex << static_cast(c); + + return os; + } +#endif + + std::ostream& operator<<(std::ostream& os, char16_t const& c) + { + os << "\\u" << std::setfill('0') << std::setw(4) << std::right << std::hex << static_cast(c); + + return os; + } + + std::ostream& operator<<(std::ostream& os, char32_t const& c) + { + os << "\\U" << std::setfill('0') << std::setw(8) << std::right << std::hex << static_cast(c); + + return os; + } + } // namespace std namespace { diff --git a/src/test-helper.h b/src/test-helper.h index c3e2900..676af73 100644 --- a/src/test-helper.h +++ b/src/test-helper.h @@ -14,6 +14,12 @@ namespace std { std::ostream& operator<<(std::ostream& os, std::basic_string const& s); std::ostream& operator<<(std::ostream& os, std::basic_string const& s); +#ifdef __cpp_char8_t + std::ostream& operator<<(std::ostream& os, utf8_t const& c); +#endif + std::ostream& operator<<(std::ostream& os, char16_t const& c); + std::ostream& operator<<(std::ostream& os, char32_t const& c); + } // namespace std template -- cgit v1.2.3