| 
									
										
										
										
											2013-04-08 11:44:03 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  *  Created by Phil on 6th April 2013. | 
					
						
							|  |  |  |  *  Copyright 2013 Two Blue Cubes Ltd. All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  Distributed under the Boost Software License, Version 1.0. (See accompanying | 
					
						
							|  |  |  |  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #ifndef TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_HPP_INCLUDED
 | 
					
						
							|  |  |  | #define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_HPP_INCLUDED
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "catch_legacy_reporter_adapter.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Catch | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-05-28 18:39:32 +01:00
										 |  |  |     LegacyReporterAdapter::LegacyReporterAdapter( Ptr<IReporter> const& legacyReporter ) | 
					
						
							|  |  |  |     :   m_legacyReporter( legacyReporter ) | 
					
						
							| 
									
										
										
										
											2013-04-08 11:44:03 +01:00
										 |  |  |     {} | 
					
						
							|  |  |  |     LegacyReporterAdapter::~LegacyReporterAdapter() {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ReporterPreferences LegacyReporterAdapter::getPreferences() const { | 
					
						
							|  |  |  |         ReporterPreferences prefs; | 
					
						
							|  |  |  |         prefs.shouldRedirectStdOut = m_legacyReporter->shouldRedirectStdout(); | 
					
						
							|  |  |  |         return prefs; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void LegacyReporterAdapter::noMatchingTestCases( std::string const& ) {} | 
					
						
							|  |  |  |     void LegacyReporterAdapter::testRunStarting( TestRunInfo const& ) { | 
					
						
							|  |  |  |         m_legacyReporter->StartTesting(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     void LegacyReporterAdapter::testGroupStarting( GroupInfo const& groupInfo ) { | 
					
						
							|  |  |  |         m_legacyReporter->StartGroup( groupInfo.name ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     void LegacyReporterAdapter::testCaseStarting( TestCaseInfo const& testInfo ) { | 
					
						
							|  |  |  |         m_legacyReporter->StartTestCase( testInfo ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     void LegacyReporterAdapter::sectionStarting( SectionInfo const& sectionInfo ) { | 
					
						
							|  |  |  |         m_legacyReporter->StartSection( sectionInfo.name, sectionInfo.description ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     void LegacyReporterAdapter::assertionStarting( AssertionInfo const& ) { | 
					
						
							|  |  |  |         // Not on legacy interface
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-28 16:25:49 +01:00
										 |  |  |     bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) { | 
					
						
							| 
									
										
										
										
											2013-04-08 11:44:03 +01:00
										 |  |  |         if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) { | 
					
						
							|  |  |  |             for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end(); | 
					
						
							|  |  |  |                     it != itEnd; | 
					
						
							|  |  |  |                     ++it ) { | 
					
						
							|  |  |  |                 if( it->type == ResultWas::Info ) { | 
					
						
							| 
									
										
										
										
											2014-05-29 07:50:19 +01:00
										 |  |  |                     ResultBuilder rb( it->macroName.c_str(), it->lineInfo, "", ResultDisposition::Normal ); | 
					
						
							|  |  |  |                     rb << it->message; | 
					
						
							|  |  |  |                     rb.setResultType( ResultWas::Info ); | 
					
						
							|  |  |  |                     AssertionResult result = rb.build(); | 
					
						
							| 
									
										
										
										
											2013-04-08 11:44:03 +01:00
										 |  |  |                     m_legacyReporter->Result( result ); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2013-07-03 19:14:59 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-04-08 11:44:03 +01:00
										 |  |  |         m_legacyReporter->Result( assertionStats.assertionResult ); | 
					
						
							| 
									
										
										
										
											2013-06-28 16:25:49 +01:00
										 |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2013-04-08 11:44:03 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) { | 
					
						
							|  |  |  |         if( sectionStats.missingAssertions ) | 
					
						
							|  |  |  |             m_legacyReporter->NoAssertionsInSection( sectionStats.sectionInfo.name ); | 
					
						
							|  |  |  |         m_legacyReporter->EndSection( sectionStats.sectionInfo.name, sectionStats.assertions ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     void LegacyReporterAdapter::testCaseEnded( TestCaseStats const& testCaseStats ) { | 
					
						
							|  |  |  |         m_legacyReporter->EndTestCase | 
					
						
							|  |  |  |             (   testCaseStats.testInfo, | 
					
						
							|  |  |  |                 testCaseStats.totals, | 
					
						
							|  |  |  |                 testCaseStats.stdOut, | 
					
						
							|  |  |  |                 testCaseStats.stdErr ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     void LegacyReporterAdapter::testGroupEnded( TestGroupStats const& testGroupStats ) { | 
					
						
							|  |  |  |         if( testGroupStats.aborting ) | 
					
						
							|  |  |  |             m_legacyReporter->Aborted(); | 
					
						
							|  |  |  |         m_legacyReporter->EndGroup( testGroupStats.groupInfo.name, testGroupStats.totals ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     void LegacyReporterAdapter::testRunEnded( TestRunStats const& testRunStats ) { | 
					
						
							|  |  |  |         m_legacyReporter->EndTesting( testRunStats.totals ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-12-22 20:10:33 +00:00
										 |  |  |     void LegacyReporterAdapter::skipTest( TestCaseInfo const& ) { | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-04-08 11:44:03 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED
 |