Fix colors in output of TestSamples (#3332)

This commit is contained in:
Paul Fultz II 2021-07-10 13:14:38 -05:00 committed by GitHub
parent 009c144455
commit afac0e8ad3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -101,6 +101,11 @@ private:
setSettings(set); setSettings(set);
} }
#ifndef _WIN32
virtual void reportOut(const std::string &outmsg, Color = Color::Reset) override {
std::cout << outmsg << std::endl;
}
#endif
}; };
void runConsoleCodePageTranslationOnWindows() const { void runConsoleCodePageTranslationOnWindows() const {

View File

@ -23,6 +23,7 @@
#include "redirect.h" #include "redirect.h"
#include <cstdio> #include <cstdio>
#include <cctype>
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -124,8 +125,10 @@ static std::string writestr(const std::string &str, bool gccStyle = false)
ostr << "\\t"; ostr << "\\t";
else if (*i == '\"') else if (*i == '\"')
ostr << "\\\""; ostr << "\\\"";
else else if (std::isprint(static_cast<unsigned char>(*i)))
ostr << *i; ostr << *i;
else
ostr << "\\x" << std::hex << short{*i};
} }
if (!str.empty() && !gccStyle) if (!str.empty() && !gccStyle)
ostr << std::endl; ostr << std::endl;