@@ -61,14 +61,24 @@ const char UNITY_PROGMEM UnityStrErrShorthand[] = "Unity Shorth
6161const char UNITY_PROGMEM UnityStrErrFloat [] = "Unity Floating Point Disabled" ;
6262const char UNITY_PROGMEM UnityStrErrDouble [] = "Unity Double Precision Disabled" ;
6363const char UNITY_PROGMEM UnityStrErr64 [] = "Unity 64-bit Support Disabled" ;
64+ const char UNITY_PROGMEM UnityStrErrDetailStack [] = "Unity Detail Stack Support Disabled" ;
6465static const char UNITY_PROGMEM UnityStrBreaker [] = "-----------------------" ;
6566static const char UNITY_PROGMEM UnityStrResultsTests [] = " Tests " ;
6667static const char UNITY_PROGMEM UnityStrResultsFailures [] = " Failures " ;
6768static const char UNITY_PROGMEM UnityStrResultsIgnored [] = " Ignored " ;
6869#ifndef UNITY_EXCLUDE_DETAILS
70+ #ifdef UNITY_DETAIL_STACK_SIZE
71+ static const char * UNITY_PROGMEM UnityStrDetailLabels [] = UNITY_DETAIL_LABEL_NAMES ;
72+ static const UNITY_COUNTER_TYPE UNITY_PROGMEM UnityStrDetailLabelsCount = sizeof (UnityStrDetailLabels ) / sizeof (const char * );
73+ static const char UNITY_PROGMEM UnityStrErrDetailStackEmpty [] = " Detail Stack Empty" ;
74+ static const char UNITY_PROGMEM UnityStrErrDetailStackFull [] = " Detail Stack Full" ;
75+ static const char UNITY_PROGMEM UnityStrErrDetailStackLabel [] = " Detail Label Outside Of UNITY_DETAIL_LABEL_NAMES: " ;
76+ static const char UNITY_PROGMEM UnityStrErrDetailStackPop [] = " Detail Pop With Unexpected Arguments" ;
77+ #else
6978static const char UNITY_PROGMEM UnityStrDetail1Name [] = UNITY_DETAIL1_NAME " " ;
7079static const char UNITY_PROGMEM UnityStrDetail2Name [] = " " UNITY_DETAIL2_NAME " " ;
7180#endif
81+ #endif
7282/*-----------------------------------------------
7383 * Pretty Printers & Test Result Output Handlers
7484 *-----------------------------------------------*/
@@ -574,6 +584,28 @@ static void UnityAddMsgIfSpecified(const char* msg)
574584 UNITY_PRINT_TEST_CONTEXT ();
575585#endif
576586#ifndef UNITY_EXCLUDE_DETAILS
587+ #ifdef UNITY_DETAIL_STACK_SIZE
588+ {
589+ UNITY_COUNTER_TYPE c ;
590+ for (c = 0 ; (c < Unity .CurrentDetailStackSize ) && (c < UNITY_DETAIL_STACK_SIZE ); c ++ ) {
591+ const char * label ;
592+ if ((Unity .CurrentDetailStackLabels [c ] == UNITY_DETAIL_NONE ) || (Unity .CurrentDetailStackLabels [c ] > UnityStrDetailLabelsCount )) {
593+ break ;
594+ }
595+ label = UnityStrDetailLabels [Unity .CurrentDetailStackLabels [c ]];
596+ UnityPrint (UnityStrSpacer );
597+ if ((label [0 ] == '#' ) && (label [1 ] != 0 )) {
598+ UnityPrint (label + 2 );
599+ UNITY_OUTPUT_CHAR (' ' );
600+ UnityPrintNumberByStyle (Unity .CurrentDetailStackValues [c ], label [1 ]);
601+ } else if (Unity .CurrentDetailStackValues [c ] != 0 ){
602+ UnityPrint (label );
603+ UNITY_OUTPUT_CHAR (' ' );
604+ UnityPrint ((const char * )Unity .CurrentDetailStackValues [c ]);
605+ }
606+ }
607+ }
608+ #else
577609 if (Unity .CurrentDetail1 )
578610 {
579611 UnityPrint (UnityStrSpacer );
@@ -585,6 +617,7 @@ static void UnityAddMsgIfSpecified(const char* msg)
585617 UnityPrint (Unity .CurrentDetail2 );
586618 }
587619 }
620+ #endif
588621#endif
589622 if (msg )
590623 {
@@ -2127,32 +2160,7 @@ void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
21272160
21282161 UnityTestResultsBegin (Unity .TestFile , line );
21292162 UnityPrint (UnityStrFail );
2130- if (msg != NULL )
2131- {
2132- UNITY_OUTPUT_CHAR (':' );
2133-
2134- #ifdef UNITY_PRINT_TEST_CONTEXT
2135- UNITY_PRINT_TEST_CONTEXT ();
2136- #endif
2137- #ifndef UNITY_EXCLUDE_DETAILS
2138- if (Unity .CurrentDetail1 )
2139- {
2140- UnityPrint (UnityStrDetail1Name );
2141- UnityPrint (Unity .CurrentDetail1 );
2142- if (Unity .CurrentDetail2 )
2143- {
2144- UnityPrint (UnityStrDetail2Name );
2145- UnityPrint (Unity .CurrentDetail2 );
2146- }
2147- UnityPrint (UnityStrSpacer );
2148- }
2149- #endif
2150- if (msg [0 ] != ' ' )
2151- {
2152- UNITY_OUTPUT_CHAR (' ' );
2153- }
2154- UnityPrint (msg );
2155- }
2163+ UnityAddMsgIfSpecified (msg );
21562164
21572165 UNITY_FAIL_AND_BAIL ;
21582166}
@@ -2195,7 +2203,13 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
21952203 Unity .CurrentTestName = FuncName ;
21962204 Unity .CurrentTestLineNumber = (UNITY_LINE_TYPE )FuncLineNum ;
21972205 Unity .NumberOfTests ++ ;
2206+ #ifndef UNITY_EXCLUDE_DETAILS
2207+ #ifdef UNITY_DETAIL_STACK_SIZE
2208+ Unity .CurrentDetailStackSize = 0 ;
2209+ #else
21982210 UNITY_CLR_DETAILS ();
2211+ #endif
2212+ #endif
21992213 UNITY_EXEC_TIME_START ();
22002214 if (TEST_PROTECT ())
22012215 {
@@ -2263,6 +2277,46 @@ int UnityEnd(void)
22632277 return (int )(Unity .TestFailures );
22642278}
22652279
2280+ /*-----------------------------------------------
2281+ * Details Stack
2282+ *-----------------------------------------------*/
2283+ #ifndef UNITY_EXCLUDE_DETAILS
2284+ #ifdef UNITY_DETAIL_STACK_SIZE
2285+ void UnityPushDetail (UNITY_DETAIL_LABEL_TYPE label , UNITY_DETAIL_VALUE_TYPE value , const UNITY_LINE_TYPE line ) {
2286+ if (Unity .CurrentDetailStackSize >= UNITY_DETAIL_STACK_SIZE ) {
2287+ UnityTestResultsFailBegin (line );
2288+ UnityPrint (UnityStrErrDetailStackFull );
2289+ UnityAddMsgIfSpecified (NULL );
2290+ UNITY_FAIL_AND_BAIL ;
2291+ }
2292+ if (label >= UnityStrDetailLabelsCount ) {
2293+ UnityTestResultsFailBegin (line );
2294+ UnityPrint (UnityStrErrDetailStackLabel );
2295+ UnityPrintNumberUnsigned (label );
2296+ UnityAddMsgIfSpecified (NULL );
2297+ UNITY_FAIL_AND_BAIL ;
2298+ }
2299+ Unity .CurrentDetailStackLabels [Unity .CurrentDetailStackSize ] = label ;
2300+ Unity .CurrentDetailStackValues [Unity .CurrentDetailStackSize ++ ] = value ;
2301+ }
2302+ void UnityPopDetail (UNITY_DETAIL_LABEL_TYPE label , UNITY_DETAIL_VALUE_TYPE value , const UNITY_LINE_TYPE line ) {
2303+ if (Unity .CurrentDetailStackSize == 0 ) {
2304+ UnityTestResultsFailBegin (line );
2305+ UnityPrint (UnityStrErrDetailStackEmpty );
2306+ UnityAddMsgIfSpecified (NULL );
2307+ UNITY_FAIL_AND_BAIL ;
2308+ }
2309+ if ((Unity .CurrentDetailStackLabels [Unity .CurrentDetailStackSize - 1 ] != label ) || (Unity .CurrentDetailStackValues [Unity .CurrentDetailStackSize - 1 ] != value )) {
2310+ UnityTestResultsFailBegin (line );
2311+ UnityPrint (UnityStrErrDetailStackPop );
2312+ UnityAddMsgIfSpecified (NULL );
2313+ UNITY_FAIL_AND_BAIL ;
2314+ }
2315+ Unity .CurrentDetailStackSize -- ;
2316+ }
2317+ #endif
2318+ #endif
2319+
22662320/*-----------------------------------------------
22672321 * Command Line Argument Support
22682322 *-----------------------------------------------*/
0 commit comments