@@ -73,6 +73,7 @@ class TestClass
7373 , m_failure_check_count(0 )
7474 , m_test_number(0 )
7575 , m_logged(false )
76+ , m_multi_line_errors(false )
7677 {
7778 GetSharedData ().SetClassName (class_name);
7879
@@ -320,6 +321,16 @@ class TestClass
320321 return m_current_time;
321322 }
322323
324+ bool GetMultiLineErrors () const
325+ {
326+ return m_multi_line_errors;
327+ }
328+
329+ void LogMultiLineErrors (bool multi_line_errors)
330+ {
331+ m_multi_line_errors = multi_line_errors;
332+ }
333+
323334 void LogTests ()
324335 {
325336 if (m_logged)
@@ -556,6 +567,7 @@ class TestClass
556567 if (time_complete && (m_timed_function_calls < min_iterations))
557568 {
558569 ++m_failure_check_count;
570+ GetSharedData ().IncTotalFailedChecks ();
559571 TestString error;
560572 error.Append (m_timed_function_calls);
561573 error.Append (" iterations less than expected " );
@@ -697,6 +709,7 @@ class TestClass
697709 if (failed)
698710 {
699711 ++m_failure_check_count;
712+ GetSharedData ().IncTotalFailedChecks ();
700713 privateCheckFailed (expression, line_number);
701714 }
702715
@@ -890,7 +903,7 @@ class TestClass
890903 }
891904
892905 // Log the output for a failed check macro.
893- void privateLogFailures ()
906+ void privateLogFailuresMultiLine ()
894907 {
895908 TestString const indent (' ' , error_padding);
896909
@@ -913,17 +926,53 @@ class TestClass
913926 {
914927 m_check_failures.GetSubString (msg, 0 , pos + 1 , true );
915928 msg.Prepend (indent);
916- LogWrite (msg);
917929 }
918930 else
919931 {
920- m_check_failures.Prepend (indent);
921- LogWrite (m_check_failures);
932+ msg.Assign (indent);
933+ msg.Append (m_check_failures);
934+ m_check_failures.Clear ();
935+ }
936+ LogWrite (msg);
937+ }
938+ }
939+
940+ void privateLogFailuresSingleLine ()
941+ {
942+ TestString const indent (' ' , error_padding);
943+
944+ TestString msg;
945+
946+ // Extract each line from the string until there are no more failed checks.
947+ while (!m_check_failures.IsEmpty ())
948+ {
949+ ocl_size_type pos = 0 ;
950+ msg.Append (indent);
951+ msg.Append (m_filename);
952+ if (m_check_failures.Find (' \n ' , pos))
953+ {
954+ TestString submsg;
955+ m_check_failures.GetSubString (submsg, 0 , pos + 1 , true );
956+ msg.Append (submsg);
957+ }
958+ else
959+ {
960+ msg.Append (m_check_failures);
922961 m_check_failures.Clear ();
923962 }
963+ LogWrite (msg);
964+ msg.Clear ();
924965 }
925966 }
926967
968+ void privateLogFailures ()
969+ {
970+ if (m_multi_line_errors)
971+ privateLogFailuresMultiLine ();
972+ else
973+ privateLogFailuresSingleLine ();
974+ }
975+
927976 // Log the number of checks for a tested function, e.g. 5 TESTS or 1 TEST.
928977 static void privateLogCount (TestString const & msg, ocl_size_type count)
929978 {
@@ -941,14 +990,14 @@ class TestClass
941990 {
942991 GetLogger ()->WriteEOL ();
943992 privateLogCount (" Total checks" , GetSharedData ().GetTotalChecks ());
944- if (GetSharedData ().GetTotalNotTested () > 0 )
945- privateLogCount (" Total not tested" , GetSharedData ().GetTotalNotTested ());
946993 if (HasSharedFailure ())
947994 privateLogCount (" Total failed checks" , GetSharedData ().GetTotalFailedChecks ());
995+ if (GetSharedData ().GetTotalNotTested () > 0 )
996+ privateLogCount (" Total functions not tested" , GetSharedData ().GetTotalNotTested ());
948997 privateLogCount (" Total functions tested" , GetSharedData ().GetTotalFunctionsTested ());
949998 if (GetSharedData ().GetTotalTimedFunctions () > 0 )
950999 privateLogCount (" Total functions timed" , GetSharedData ().GetTotalTimedFunctions ());
951- privateLogCount (" Total tests" , GetSharedData ().GetTotalTests ());
1000+ privateLogCount (" Total function tests" , GetSharedData ().GetTotalTests ());
9521001 if (GetSharedData ().GetTotalLeakedTests () > 0 )
9531002 privateLogCount (" Total memory leaks" , GetSharedData ().GetTotalLeakedTests ());
9541003 }
@@ -983,19 +1032,31 @@ class TestClass
9831032 void privateCheckFailed (TestString const & expression,
9841033 ocl_size_type line_number)
9851034 {
1035+ // If multi line, display line and expression on separate lines.
1036+ // For single line errors, display filename, line number in brackets, ": error: EXPRESSION: " and expression last.
9861037 if (line_number > 0 )
9871038 {
988- GetSharedData ().IncTotalFailedChecks ();
989- m_check_failures.Append (" LINE: " );
990- m_check_failures.Append (static_cast <unsigned long >(line_number));
991- m_check_failures.Append (" \n " );
1039+ if (m_multi_line_errors)
1040+ {
1041+ m_check_failures.Append (" LINE: " );
1042+ m_check_failures.Append (static_cast <unsigned long >(line_number));
1043+ m_check_failures.Append (" \n " );
1044+ }
1045+ else
1046+ {
1047+ m_check_failures.Append (" (" );
1048+ m_check_failures.Append (static_cast <unsigned long >(line_number));
1049+ m_check_failures.Append (" ): error: " );
1050+ }
9921051 }
9931052 if ((expression != NULL ) && (*expression != ' \0 ' ))
9941053 {
9951054 m_check_failures.Append (" EXPRESSION: " );
9961055 m_check_failures.Append (expression);
9971056 m_check_failures.Append (" \n " );
9981057 }
1058+ else if (!m_multi_line_errors)
1059+ m_check_failures.Append (" \n " ); // Always ensure at least one new line exists.
9991060 }
10001061
10011062private:
@@ -1061,6 +1122,10 @@ class TestClass
10611122 // Only log test results once.
10621123 bool m_logged;
10631124
1125+ // Log errors across multiple lines for a single file,
1126+ // or each error with each file on the same line.
1127+ bool m_multi_line_errors;
1128+
10641129private:
10651130 TestClass (TestClass const &);
10661131 TestClass& operator =(TestClass const &);
0 commit comments