diff options
Diffstat (limited to 'src/test-helper.h')
-rw-r--r-- | src/test-helper.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test-helper.h b/src/test-helper.h new file mode 100644 index 0000000..c3e2900 --- /dev/null +++ b/src/test-helper.h @@ -0,0 +1,39 @@ +#pragma once + +#include <unicode.h> + +#include <string> + +// output operators must be in same namespace as the type itself +namespace std { + +#ifdef __cpp_char8_t + std::ostream& operator<<(std::ostream& os, std::basic_string<utf8_t> const& s); +#endif + + std::ostream& operator<<(std::ostream& os, std::basic_string<char16_t> const& s); + std::ostream& operator<<(std::ostream& os, std::basic_string<char32_t> const& s); + +} // namespace std + +template<typename From, typename To> +std::basic_string<To> std_convert(const std::basic_string<From>& s); + +template<> +std::basic_string<utf8_t> std_convert<utf8_t, utf8_t>(const std::basic_string<utf8_t>& s); +template<> +std::basic_string<char16_t> std_convert<utf8_t, char16_t>(const std::basic_string<utf8_t>& s); +template<> +std::basic_string<char32_t> std_convert<utf8_t, char32_t>(const std::basic_string<utf8_t>& s); +template<> +std::basic_string<utf8_t> std_convert<char16_t, utf8_t>(const std::basic_string<char16_t>& s); +template<> +std::basic_string<char16_t> std_convert<char16_t, char16_t>(const std::basic_string<char16_t>& s); +template<> +std::basic_string<char32_t> std_convert<char16_t, char32_t>(const std::basic_string<char16_t>& s); +template<> +std::basic_string<utf8_t> std_convert<char32_t, utf8_t>(const std::basic_string<char32_t>& s); +template<> +std::basic_string<char16_t> std_convert<char32_t, char16_t>(const std::basic_string<char32_t>& s); +template<> +std::basic_string<char32_t> std_convert<char32_t, char32_t>(const std::basic_string<char32_t>& s); |