| 
									
										
										
										
											2012-02-15 08:20:06 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  *  Created by Phil on 14/02/2012. | 
					
						
							|  |  |  |  *  Copyright 2012 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)
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-16 18:47:41 +01:00
										 |  |  | #ifdef __clang__
 | 
					
						
							| 
									
										
										
										
											2012-08-13 07:46:10 +01:00
										 |  |  | #pragma clang diagnostic ignored "-Wpadded"
 | 
					
						
							| 
									
										
										
										
											2012-08-16 18:47:41 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2012-08-13 07:46:10 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-15 08:20:06 +00:00
										 |  |  | #define CATCH_CONFIG_MAIN
 | 
					
						
							|  |  |  | #include "catch_self_test.hpp"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-04 07:55:11 +01:00
										 |  |  | namespace Catch{ | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2012-08-15 19:12:51 +01:00
										 |  |  |     Totals EmbeddedRunner::runMatching( const std::string& rawTestSpec, const std::string& ) { | 
					
						
							| 
									
										
										
										
											2012-02-15 08:20:06 +00:00
										 |  |  |         std::ostringstream oss; | 
					
						
							|  |  |  |         Config config; | 
					
						
							|  |  |  |         config.setStreamBuf( oss.rdbuf() ); | 
					
						
							| 
									
										
										
										
											2012-05-04 07:55:11 +01:00
										 |  |  |          | 
					
						
							| 
									
										
										
										
											2012-08-15 19:12:51 +01:00
										 |  |  |         Totals totals; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-15 08:20:06 +00:00
										 |  |  |         // Scoped because Runner doesn't report EndTesting until its destructor
 | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2012-11-30 19:15:23 +00:00
										 |  |  |             Runner runner( config, new LegacyReporterAdapter( m_reporter.get(), ReporterConfig( config.stream(), config.data() ) ) ); | 
					
						
							| 
									
										
										
										
											2012-08-15 19:12:51 +01:00
										 |  |  |             totals = runner.runMatching( rawTestSpec ); | 
					
						
							| 
									
										
										
										
											2012-02-15 08:20:06 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         m_output = oss.str(); | 
					
						
							| 
									
										
										
										
											2012-08-15 19:12:51 +01:00
										 |  |  |         return totals; | 
					
						
							| 
									
										
										
										
											2012-02-15 08:20:06 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-05-07 18:59:33 +01:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2012-10-16 08:31:05 +01:00
										 |  |  |     void MockReporter::Result( const AssertionResult& assertionResult ) { | 
					
						
							|  |  |  |         if( assertionResult.getResultType() == ResultWas::Ok ) | 
					
						
							| 
									
										
										
										
											2012-05-07 18:59:33 +01:00
										 |  |  |             return; | 
					
						
							| 
									
										
										
										
											2012-11-04 21:39:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         m_log << assertionResult.getSourceInfo() << " "; | 
					
						
							| 
									
										
										
										
											2012-05-07 18:59:33 +01:00
										 |  |  |          | 
					
						
							| 
									
										
										
										
											2012-10-16 08:31:05 +01:00
										 |  |  |         switch( assertionResult.getResultType() ) {           | 
					
						
							| 
									
										
										
										
											2012-05-07 18:59:33 +01:00
										 |  |  |             case ResultWas::Info: | 
					
						
							|  |  |  |                 m_log << "Info"; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case ResultWas::Warning: | 
					
						
							|  |  |  |                 m_log << "Warning"; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case ResultWas::ExplicitFailure: | 
					
						
							|  |  |  |                 m_log << "ExplicitFailure"; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case ResultWas::ExpressionFailed: | 
					
						
							|  |  |  |                 m_log << "ExpressionFailed"; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case ResultWas::Unknown: | 
					
						
							|  |  |  |                 m_log << "Unknown"; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case ResultWas::ThrewException: | 
					
						
							|  |  |  |                 m_log << "ThrewException"; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case ResultWas::DidntThrowException: | 
					
						
							|  |  |  |                 m_log << "DidntThrowException"; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             // We shouldn't ever see these
 | 
					
						
							|  |  |  |             case ResultWas::Ok: | 
					
						
							|  |  |  |                 m_log << "Ok"; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case ResultWas::FailureBit: | 
					
						
							|  |  |  |                 m_log << "FailureBit"; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case ResultWas::Exception: | 
					
						
							|  |  |  |                 m_log << "Exception"; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |          | 
					
						
							| 
									
										
										
										
											2012-10-16 08:31:05 +01:00
										 |  |  |         if( assertionResult.hasExpression() ) | 
					
						
							|  |  |  |             m_log << assertionResult.getExpression(); | 
					
						
							| 
									
										
										
										
											2012-05-07 18:59:33 +01:00
										 |  |  |          | 
					
						
							| 
									
										
										
										
											2012-10-16 08:31:05 +01:00
										 |  |  |         if( assertionResult.hasMessage() ) | 
					
						
							|  |  |  |             m_log << "'" << assertionResult.getMessage() << "'"; | 
					
						
							| 
									
										
										
										
											2012-05-07 18:59:33 +01:00
										 |  |  |          | 
					
						
							| 
									
										
										
										
											2012-10-16 08:31:05 +01:00
										 |  |  |         if( assertionResult.hasExpandedExpression() ) | 
					
						
							|  |  |  |             m_log << assertionResult.getExpandedExpression();         | 
					
						
							| 
									
										
										
										
											2012-05-07 18:59:33 +01:00
										 |  |  |     }     | 
					
						
							| 
									
										
										
										
											2012-05-04 07:55:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-16 15:02:51 +01:00
										 |  |  |     void MockReporter::openLabel( const std::string& label, const std::string& arg ) { | 
					
						
							|  |  |  |         if( shouldRecord( label ) ) { | 
					
						
							| 
									
										
										
										
											2012-05-07 18:59:33 +01:00
										 |  |  |             m_log << m_indent << "\\" << label; | 
					
						
							|  |  |  |             if( !arg.empty() ) | 
					
						
							|  |  |  |                 m_log << " " << arg; | 
					
						
							|  |  |  |             m_log << "\n"; | 
					
						
							|  |  |  |             m_indent += " "; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2012-05-16 15:02:51 +01:00
										 |  |  |     void MockReporter::closeLabel( const std::string& label, const std::string& arg ) { | 
					
						
							|  |  |  |         if( shouldRecord( label ) ) { | 
					
						
							| 
									
										
										
										
											2012-05-07 18:59:33 +01:00
										 |  |  |             m_indent = m_indent.substr( 0, m_indent.size()-1 ); | 
					
						
							|  |  |  |             m_log << m_indent << "/" << label; | 
					
						
							|  |  |  |             if( !arg.empty() ) | 
					
						
							|  |  |  |                 m_log << " " << arg; | 
					
						
							|  |  |  |             m_log << "\n"; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |          | 
					
						
							| 
									
										
										
										
											2012-05-04 07:55:11 +01:00
										 |  |  |     const std::string MockReporter::recordGroups = "[g]"; | 
					
						
							|  |  |  |     const std::string MockReporter::recordTestCases = "[tc]"; | 
					
						
							|  |  |  |     const std::string MockReporter::recordSections =" [s]"; | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2012-11-30 19:29:03 +00:00
										 |  |  |     INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( "mock", MockReporter ) | 
					
						
							| 
									
										
										
										
											2012-05-04 07:55:11 +01:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2012-02-15 18:36:36 +00:00
										 |  |  | } |