Skip to content

Commit addc50e

Browse files
committed
refactor: simplify color output handling in StdOutReport
1 parent 3144b2f commit addc50e

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

cucumber_cpp/library/report/StdOutReport.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,27 @@ namespace cucumber_cpp::library::report
3737
namespace
3838
{
3939
#ifndef _MSC_VER
40-
constexpr auto redStr{ "\o{33}[1m\o{33}[31m" };
41-
constexpr auto greenStr{ "\o{33}[1m\o{33}[32m" };
42-
constexpr auto cyanStr{ "\o{33}[1m\o{33}[36m" };
43-
constexpr auto defaultStr{ "\o{33}[0m\o{33}[39m" };
44-
4540
inline std::ostream& TcRed(std::ostream& o)
4641
{
47-
o << redStr;
42+
o << "\o{33}[1m\o{33}[31m";
4843
return o;
4944
}
5045

5146
inline std::ostream& TcGreen(std::ostream& o)
5247
{
53-
o << greenStr;
48+
o << "\o{33}[1m\o{33}[32m";
5449
return o;
5550
}
5651

5752
inline std::ostream& TcCyan(std::ostream& o)
5853
{
59-
o << cyanStr;
54+
o << "\o{33}[1m\o{33}[36m";
6055
return o;
6156
}
6257

6358
inline std::ostream& TcDefault(std::ostream& o)
6459
{
65-
o << defaultStr;
60+
o << "\o{33}[0m\o{33}[39m";
6661
return o;
6762
}
6863
#else
@@ -211,14 +206,16 @@ namespace cucumber_cpp::library::report
211206
void StdOutReport::StepMissing(const std::string& stepText)
212207
{
213208
std::cout << "\n"
214-
<< std::format(R"({}Step missing: "{}")", redStr, stepText);
209+
<< TcRed
210+
<< std::format(R"(Step missing: "{}")", stepText);
215211
std::cout << TcDefault;
216212
}
217213

218214
void StdOutReport::StepAmbiguous(const std::string& stepText, const engine::StepInfo& stepInfo)
219215
{
220216
std::cout << "\n"
221-
<< std::format(R"({}Ambiguous step: "{}" Matches:)", redStr, stepText);
217+
<< TcRed
218+
<< std::format(R"(Ambiguous step: "{}" Matches:)", stepText);
222219

223220
for (const auto& match : std::get<std::vector<StepRegistry::StepMatch>>(stepInfo.StepMatch()))
224221
{

0 commit comments

Comments
 (0)