-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reporters now use colors for output by default. Colors can be turned off with the "--no-color" option from the command line. Addresses issue: #8 added colorizer colorizer called from reporters options parser "--no-color" option colors can be turned off with "--no-colors"
- Loading branch information
1 parent
597896e
commit 5a632b4
Showing
12 changed files
with
135 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
set makeprg=make\ -C../build-clang;\ cd\ $PWD | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef BANDIT_REPORTERS_COLORIZER_H | ||
#define BANDIT_REPORTERS_COLORIZER_H | ||
|
||
namespace bandit { namespace detail { | ||
|
||
struct colorizer | ||
{ | ||
colorizer(bool colors_enabled = true) | ||
: colors_enabled_(colors_enabled) | ||
{} | ||
|
||
const char* green() const | ||
{ | ||
return colors_enabled_ ? "\033[1;32m" : ""; | ||
} | ||
|
||
const char* red() const | ||
{ | ||
return colors_enabled_ ? "\033[1;31m" : ""; | ||
} | ||
|
||
const char* reset() const | ||
{ | ||
return colors_enabled_ ? "\033[0m" : ""; | ||
} | ||
|
||
private: | ||
bool colors_enabled_; | ||
}; | ||
|
||
}} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <specs/specs.h> | ||
|
||
go_bandit([](){ | ||
|
||
describe("colorizer: ", [&](){ | ||
|
||
describe("colors enabled", [&](){ | ||
bandit::detail::colorizer colorizer; | ||
|
||
it("can set color to green", [&](){ | ||
AssertThat(colorizer.green(), Equals("\033[1;32m")); | ||
}); | ||
|
||
it("set color to red", [&](){ | ||
AssertThat(colorizer.red(), Equals("\033[1;31m")); | ||
}); | ||
it("resets color", [&](){ | ||
AssertThat(colorizer.reset(), Equals("\033[0m")); | ||
}); | ||
|
||
}); | ||
|
||
describe("colors disabled", [&](){ | ||
|
||
bandit::detail::colorizer colorizer(false); | ||
|
||
it("ignores setting color to green", [&](){ | ||
AssertThat(colorizer.green(), Equals("")); | ||
}); | ||
|
||
it("ignores setting color to red", [&](){ | ||
AssertThat(colorizer.red(), Equals("")); | ||
}); | ||
|
||
it("ignores resetting colors", [&](){ | ||
AssertThat(colorizer.reset(), Equals("")); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters