mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-10-20 13:54:26 +08:00
- 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
This commit is contained in:
@ -254,6 +254,7 @@ class UnityTestRunnerGenerator
|
|||||||
output.puts(" Unity.CurrentTestLineNumber = TestLineNum; \\")
|
output.puts(" Unity.CurrentTestLineNumber = TestLineNum; \\")
|
||||||
output.puts(" Unity.NumberOfTests++; \\")
|
output.puts(" Unity.NumberOfTests++; \\")
|
||||||
output.puts(" CMock_Init(); \\") unless (used_mocks.empty?)
|
output.puts(" CMock_Init(); \\") unless (used_mocks.empty?)
|
||||||
|
output.puts(" UNITY_CLR_DETAILS(); \\") unless (used_mocks.empty?)
|
||||||
output.puts(" if (TEST_PROTECT()) \\")
|
output.puts(" if (TEST_PROTECT()) \\")
|
||||||
output.puts(" { \\")
|
output.puts(" { \\")
|
||||||
output.puts(" CEXCEPTION_T e; \\") if cexception
|
output.puts(" CEXCEPTION_T e; \\") if cexception
|
||||||
|
@ -42,6 +42,8 @@ const char UnityStrBreaker[] = "-----------------------";
|
|||||||
const char UnityStrResultsTests[] = " Tests ";
|
const char UnityStrResultsTests[] = " Tests ";
|
||||||
const char UnityStrResultsFailures[] = " Failures ";
|
const char UnityStrResultsFailures[] = " Failures ";
|
||||||
const char UnityStrResultsIgnored[] = " Ignored ";
|
const char UnityStrResultsIgnored[] = " Ignored ";
|
||||||
|
const char UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " ";
|
||||||
|
const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " ";
|
||||||
|
|
||||||
#ifdef UNITY_FLOAT_NEEDS_ZERO
|
#ifdef UNITY_FLOAT_NEEDS_ZERO
|
||||||
// Dividing by these constants produces +/- infinity.
|
// Dividing by these constants produces +/- infinity.
|
||||||
@ -368,13 +370,14 @@ static void UnityAddMsgIfSpecified(const char* msg)
|
|||||||
#ifndef UNITY_EXCLUDE_DETAILS
|
#ifndef UNITY_EXCLUDE_DETAILS
|
||||||
if (Unity.CurrentDetail1)
|
if (Unity.CurrentDetail1)
|
||||||
{
|
{
|
||||||
|
UnityPrint(UnityStrDetail1Name);
|
||||||
UnityPrint(Unity.CurrentDetail1);
|
UnityPrint(Unity.CurrentDetail1);
|
||||||
UnityPrint(UnityStrSpacer);
|
|
||||||
if (Unity.CurrentDetail2)
|
if (Unity.CurrentDetail2)
|
||||||
{
|
{
|
||||||
|
UnityPrint(UnityStrDetail2Name);
|
||||||
UnityPrint(Unity.CurrentDetail2);
|
UnityPrint(Unity.CurrentDetail2);
|
||||||
UnityPrint(UnityStrSpacer);
|
|
||||||
}
|
}
|
||||||
|
UnityPrint(UnityStrSpacer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
UnityPrint(msg);
|
UnityPrint(msg);
|
||||||
|
@ -423,14 +423,26 @@ int UnityEnd(void);
|
|||||||
void UnityConcludeTest(void);
|
void UnityConcludeTest(void);
|
||||||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum);
|
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum);
|
||||||
|
|
||||||
#ifndef UNITY_EXCLUDE_DETAILS
|
//-------------------------------------------------------
|
||||||
#define UNITY_CLR_DETAILS() { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; }
|
// Details Support
|
||||||
#define UNITY_SET_DETAIL(d1) { Unity.CurrentDetail1 = d1; Unity.CurrentDetail2 = 0; }
|
//-------------------------------------------------------
|
||||||
#define UNITY_SET_DETAILS(d1,d2) { Unity.CurrentDetail1 = d1; Unity.CurrentDetail2 = d2; }
|
|
||||||
#else
|
#ifdef UNITY_EXCLUDE_DETAILS
|
||||||
#define UNITY_CLR_DETAILS()
|
#define UNITY_CLR_DETAILS()
|
||||||
#define UNITY_SET_DETAIL(d1)
|
#define UNITY_SET_DETAIL(d1)
|
||||||
#define UNITY_SET_DETAILS(d1,d2)
|
#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
|
#endif
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
@ -569,9 +581,9 @@ extern const char UnityStrErr64[];
|
|||||||
#ifdef __STDC_VERSION__
|
#ifdef __STDC_VERSION__
|
||||||
#if __STDC_VERSION__ >= 199901L
|
#if __STDC_VERSION__ >= 199901L
|
||||||
#define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__))
|
#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_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)
|
#define RUN_TEST_SECOND_HELPER(first, second, ...) (second)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
Unity.CurrentTestLineNumber = TestLineNum; \
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
||||||
Unity.NumberOfTests++; \
|
Unity.NumberOfTests++; \
|
||||||
CMock_Init(); \
|
CMock_Init(); \
|
||||||
|
UNITY_CLR_DETAILS(); \
|
||||||
if (TEST_PROTECT()) \
|
if (TEST_PROTECT()) \
|
||||||
{ \
|
{ \
|
||||||
CEXCEPTION_T e; \
|
CEXCEPTION_T e; \
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
Unity.CurrentTestLineNumber = TestLineNum; \
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
||||||
Unity.NumberOfTests++; \
|
Unity.NumberOfTests++; \
|
||||||
CMock_Init(); \
|
CMock_Init(); \
|
||||||
|
UNITY_CLR_DETAILS(); \
|
||||||
if (TEST_PROTECT()) \
|
if (TEST_PROTECT()) \
|
||||||
{ \
|
{ \
|
||||||
setUp(); \
|
setUp(); \
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
Unity.CurrentTestLineNumber = TestLineNum; \
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
||||||
Unity.NumberOfTests++; \
|
Unity.NumberOfTests++; \
|
||||||
CMock_Init(); \
|
CMock_Init(); \
|
||||||
|
UNITY_CLR_DETAILS(); \
|
||||||
if (TEST_PROTECT()) \
|
if (TEST_PROTECT()) \
|
||||||
{ \
|
{ \
|
||||||
setUp(); \
|
setUp(); \
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
Unity.CurrentTestLineNumber = TestLineNum; \
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
||||||
Unity.NumberOfTests++; \
|
Unity.NumberOfTests++; \
|
||||||
CMock_Init(); \
|
CMock_Init(); \
|
||||||
|
UNITY_CLR_DETAILS(); \
|
||||||
if (TEST_PROTECT()) \
|
if (TEST_PROTECT()) \
|
||||||
{ \
|
{ \
|
||||||
CEXCEPTION_T e; \
|
CEXCEPTION_T e; \
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
Unity.CurrentTestLineNumber = TestLineNum; \
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
||||||
Unity.NumberOfTests++; \
|
Unity.NumberOfTests++; \
|
||||||
CMock_Init(); \
|
CMock_Init(); \
|
||||||
|
UNITY_CLR_DETAILS(); \
|
||||||
if (TEST_PROTECT()) \
|
if (TEST_PROTECT()) \
|
||||||
{ \
|
{ \
|
||||||
setUp(); \
|
setUp(); \
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
Unity.CurrentTestLineNumber = TestLineNum; \
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
||||||
Unity.NumberOfTests++; \
|
Unity.NumberOfTests++; \
|
||||||
CMock_Init(); \
|
CMock_Init(); \
|
||||||
|
UNITY_CLR_DETAILS(); \
|
||||||
if (TEST_PROTECT()) \
|
if (TEST_PROTECT()) \
|
||||||
{ \
|
{ \
|
||||||
setUp(); \
|
setUp(); \
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
Unity.CurrentTestLineNumber = TestLineNum; \
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
||||||
Unity.NumberOfTests++; \
|
Unity.NumberOfTests++; \
|
||||||
CMock_Init(); \
|
CMock_Init(); \
|
||||||
|
UNITY_CLR_DETAILS(); \
|
||||||
if (TEST_PROTECT()) \
|
if (TEST_PROTECT()) \
|
||||||
{ \
|
{ \
|
||||||
CEXCEPTION_T e; \
|
CEXCEPTION_T e; \
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
Unity.CurrentTestLineNumber = TestLineNum; \
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
||||||
Unity.NumberOfTests++; \
|
Unity.NumberOfTests++; \
|
||||||
CMock_Init(); \
|
CMock_Init(); \
|
||||||
|
UNITY_CLR_DETAILS(); \
|
||||||
if (TEST_PROTECT()) \
|
if (TEST_PROTECT()) \
|
||||||
{ \
|
{ \
|
||||||
setUp(); \
|
setUp(); \
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
Unity.CurrentTestLineNumber = TestLineNum; \
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
||||||
Unity.NumberOfTests++; \
|
Unity.NumberOfTests++; \
|
||||||
CMock_Init(); \
|
CMock_Init(); \
|
||||||
|
UNITY_CLR_DETAILS(); \
|
||||||
if (TEST_PROTECT()) \
|
if (TEST_PROTECT()) \
|
||||||
{ \
|
{ \
|
||||||
CEXCEPTION_T e; \
|
CEXCEPTION_T e; \
|
||||||
|
Reference in New Issue
Block a user