提交 28195baa 编写于 作者: M Mark VanderVoord

- Made some tweaks to the way the new detail handling works (to make it look nicer, mostly)

- Fixed a big ugly error in the fancy RUN_TEST handler
上级 dfbf21c2
......@@ -254,6 +254,7 @@ class UnityTestRunnerGenerator
output.puts(" Unity.CurrentTestLineNumber = TestLineNum; \\")
output.puts(" Unity.NumberOfTests++; \\")
output.puts(" CMock_Init(); \\") unless (used_mocks.empty?)
output.puts(" UNITY_CLR_DETAILS(); \\") unless (used_mocks.empty?)
output.puts(" if (TEST_PROTECT()) \\")
output.puts(" { \\")
output.puts(" CEXCEPTION_T e; \\") if cexception
......
......@@ -42,6 +42,8 @@ const char UnityStrBreaker[] = "-----------------------";
const char UnityStrResultsTests[] = " Tests ";
const char UnityStrResultsFailures[] = " Failures ";
const char UnityStrResultsIgnored[] = " Ignored ";
const char UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " ";
const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " ";
#ifdef UNITY_FLOAT_NEEDS_ZERO
// Dividing by these constants produces +/- infinity.
......@@ -368,13 +370,14 @@ static void UnityAddMsgIfSpecified(const char* msg)
#ifndef UNITY_EXCLUDE_DETAILS
if (Unity.CurrentDetail1)
{
UnityPrint(UnityStrDetail1Name);
UnityPrint(Unity.CurrentDetail1);
UnityPrint(UnityStrSpacer);
if (Unity.CurrentDetail2)
{
UnityPrint(UnityStrDetail2Name);
UnityPrint(Unity.CurrentDetail2);
UnityPrint(UnityStrSpacer);
}
UnityPrint(UnityStrSpacer);
}
#endif
UnityPrint(msg);
......
......@@ -423,14 +423,26 @@ int UnityEnd(void);
void UnityConcludeTest(void);
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum);
#ifndef UNITY_EXCLUDE_DETAILS
#define UNITY_CLR_DETAILS() { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; }
#define UNITY_SET_DETAIL(d1) { Unity.CurrentDetail1 = d1; Unity.CurrentDetail2 = 0; }
#define UNITY_SET_DETAILS(d1,d2) { Unity.CurrentDetail1 = d1; Unity.CurrentDetail2 = d2; }
#else
//-------------------------------------------------------
// Details Support
//-------------------------------------------------------
#ifdef UNITY_EXCLUDE_DETAILS
#define UNITY_CLR_DETAILS()
#define UNITY_SET_DETAIL(d1)
#define UNITY_SET_DETAILS(d1,d2)
#else
#define UNITY_CLR_DETAILS() { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; }
#define UNITY_SET_DETAIL(d1) { Unity.CurrentDetail1 = d1; Unity.CurrentDetail2 = 0; }
#define UNITY_SET_DETAILS(d1,d2) { Unity.CurrentDetail1 = d1; Unity.CurrentDetail2 = d2; }
#ifndef UNITY_DETAIL1_NAME
#define UNITY_DETAIL1_NAME "Function"
#endif
#ifndef UNITY_DETAIL2_NAME
#define UNITY_DETAIL2_NAME "Argument"
#endif
#endif
//-------------------------------------------------------
......@@ -569,9 +581,9 @@ extern const char UnityStrErr64[];
#ifdef __STDC_VERSION__
#if __STDC_VERSION__ >= 199901L
#define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__))
#define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(##__VA_ARGS__, throwaway)
#define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(__VA_ARGS__, throwaway)
#define RUN_TEST_FIRST_HELPER(first, ...) (first), #first
#define RUN_TEST_SECOND(...) RUN_TEST_SECOND_HELPER(##__VA_ARGS__, __LINE__, throwaway)
#define RUN_TEST_SECOND(...) RUN_TEST_SECOND_HELPER(__VA_ARGS__, __LINE__, throwaway)
#define RUN_TEST_SECOND_HELPER(first, second, ...) (second)
#endif
#endif
......
......@@ -7,6 +7,7 @@
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
CEXCEPTION_T e; \
......
......@@ -7,6 +7,7 @@
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
setUp(); \
......
......@@ -7,6 +7,7 @@
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
setUp(); \
......
......@@ -7,6 +7,7 @@
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
CEXCEPTION_T e; \
......
......@@ -7,6 +7,7 @@
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
setUp(); \
......
......@@ -8,6 +8,7 @@
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
setUp(); \
......
......@@ -7,6 +7,7 @@
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
CEXCEPTION_T e; \
......
......@@ -7,6 +7,7 @@
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
setUp(); \
......
......@@ -7,6 +7,7 @@
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
CMock_Init(); \
UNITY_CLR_DETAILS(); \
if (TEST_PROTECT()) \
{ \
CEXCEPTION_T e; \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册