提交 38c387b7 编写于 作者: M Mark VanderVoord 提交者: GitHub

Merge pull request #304 from VLambret/master

Color test results using ANSI escape codes (Thanks for the work, @VLambret !)
......@@ -337,6 +337,13 @@ things anyway, though... so this option exists for those situations.
_Example:_
#define UNITY_EXCLUDE_SETJMP
##### `UNITY_OUTPUT_COLOR`
If you want to add color using ANSI escape codes you can use this define.
t
_Example:_
#define UNITY_OUTPUT_COLOR
## Getting Into The Guts
......
......@@ -19,10 +19,17 @@ void UNITY_OUTPUT_CHAR(int);
struct UNITY_STORAGE_T Unity;
#ifdef UNITY_OUTPUT_COLOR
static const char UnityStrOk[] = "\033[42mOK\033[00m";
static const char UnityStrPass[] = "\033[42mPASS\033[00m";
static const char UnityStrFail[] = "\033[41mFAIL\033[00m";
static const char UnityStrIgnore[] = "\033[43mIGNORE\033[00m";
#else
static const char UnityStrOk[] = "OK";
static const char UnityStrPass[] = "PASS";
static const char UnityStrFail[] = "FAIL";
static const char UnityStrIgnore[] = "IGNORE";
#endif
static const char UnityStrNull[] = "NULL";
static const char UnityStrSpacer[] = ". ";
static const char UnityStrExpected[] = " Expected ";
......@@ -84,6 +91,18 @@ void UnityPrint(const char* string)
UNITY_OUTPUT_CHAR('\\');
UNITY_OUTPUT_CHAR('n');
}
#ifdef UNITY_OUTPUT_COLOR
/* print ANSI escape code */
else if (*pch == 27 && *(pch + 1) == '[')
{
while (*pch && *pch != 'm')
{
UNITY_OUTPUT_CHAR(*pch);
pch++;
}
UNITY_OUTPUT_CHAR('m');
}
#endif
/* unprintable characters are shown as codes */
else
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册