From afac0e8ad314ef8c7c820541768ce3f111b51f8e Mon Sep 17 00:00:00 2001 From: Paul Fultz II Date: Sat, 10 Jul 2021 13:14:38 -0500 Subject: [PATCH] Fix colors in output of TestSamples (#3332) --- test/testsamples.cpp | 5 +++++ test/testsuite.cpp | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/test/testsamples.cpp b/test/testsamples.cpp index f13e7cbf9..8c5a2f768 100644 --- a/test/testsamples.cpp +++ b/test/testsamples.cpp @@ -101,6 +101,11 @@ private: setSettings(set); } +#ifndef _WIN32 + virtual void reportOut(const std::string &outmsg, Color = Color::Reset) override { + std::cout << outmsg << std::endl; + } +#endif }; void runConsoleCodePageTranslationOnWindows() const { diff --git a/test/testsuite.cpp b/test/testsuite.cpp index 685cdcc59..0bd62e41c 100644 --- a/test/testsuite.cpp +++ b/test/testsuite.cpp @@ -23,6 +23,7 @@ #include "redirect.h" #include +#include #include #include @@ -124,8 +125,10 @@ static std::string writestr(const std::string &str, bool gccStyle = false) ostr << "\\t"; else if (*i == '\"') ostr << "\\\""; - else + else if (std::isprint(static_cast(*i))) ostr << *i; + else + ostr << "\\x" << std::hex << short{*i}; } if (!str.empty() && !gccStyle) ostr << std::endl;