| 
									
										
										
										
											2010-12-31 22:07:47 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  *  Created by Phil on 31/12/2010. | 
					
						
							|  |  |  |  *  Copyright 2010 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-09-17 01:42:29 -04:00
										 |  |  | #ifndef TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
 | 
					
						
							|  |  |  | #define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
 | 
					
						
							| 
									
										
										
										
											2010-12-31 22:07:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "catch_common.h"
 | 
					
						
							| 
									
										
										
										
											2012-02-24 08:59:35 +00:00
										 |  |  | #include "catch_totals.hpp"
 | 
					
						
							| 
									
										
										
										
											2012-05-04 07:55:11 +01:00
										 |  |  | #include "catch_ptr.hpp"
 | 
					
						
							| 
									
										
										
										
											2012-08-28 08:20:18 +01:00
										 |  |  | #include "catch_config.hpp"
 | 
					
						
							| 
									
										
										
										
											2010-12-31 22:07:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <string>
 | 
					
						
							|  |  |  | #include <ostream>
 | 
					
						
							| 
									
										
										
										
											2010-12-31 22:21:36 +00:00
										 |  |  | #include <map>
 | 
					
						
							| 
									
										
										
										
											2010-12-31 22:07:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Catch | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-07-20 19:07:42 +01:00
										 |  |  |     struct ReporterConfig | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ReporterConfig( const std::string& _name, | 
					
						
							|  |  |  |                         std::ostream& _stream, | 
					
						
							| 
									
										
										
										
											2012-08-28 08:20:18 +01:00
										 |  |  |                         bool _includeSuccessfulResults, | 
					
						
							|  |  |  |                         const ConfigData& _fullConfig ) | 
					
						
							| 
									
										
										
										
											2012-07-20 19:07:42 +01:00
										 |  |  |         :   name( _name ), | 
					
						
							|  |  |  |             stream( _stream ), | 
					
						
							| 
									
										
										
										
											2012-08-28 08:20:18 +01:00
										 |  |  |             includeSuccessfulResults( _includeSuccessfulResults ), | 
					
						
							|  |  |  |             fullConfig( _fullConfig ) | 
					
						
							| 
									
										
										
										
											2012-07-20 19:07:42 +01:00
										 |  |  |         {} | 
					
						
							|  |  |  |          | 
					
						
							| 
									
										
										
										
											2012-09-20 08:17:52 +01:00
										 |  |  |         ReporterConfig( const ReporterConfig& other ) | 
					
						
							|  |  |  |         :   name( other.name ), | 
					
						
							|  |  |  |             stream( other.stream ), | 
					
						
							|  |  |  |             includeSuccessfulResults( other.includeSuccessfulResults ), | 
					
						
							|  |  |  |             fullConfig( other.fullConfig ) | 
					
						
							|  |  |  |         {} | 
					
						
							|  |  |  |          | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-20 19:07:42 +01:00
										 |  |  |         std::string name; | 
					
						
							|  |  |  |         std::ostream& stream; | 
					
						
							|  |  |  |         bool includeSuccessfulResults; | 
					
						
							| 
									
										
										
										
											2012-08-28 08:20:18 +01:00
										 |  |  |         ConfigData fullConfig; | 
					
						
							| 
									
										
										
										
											2012-09-20 08:17:52 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         void operator=(const ReporterConfig&); | 
					
						
							| 
									
										
										
										
											2012-08-28 08:20:18 +01:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2010-12-31 22:07:47 +00:00
										 |  |  |      | 
					
						
							|  |  |  |     class TestCaseInfo; | 
					
						
							|  |  |  |     class ResultInfo; | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2012-05-09 08:17:51 +01:00
										 |  |  |     struct IReporter : IShared { | 
					
						
							| 
									
										
										
										
											2012-08-13 07:46:10 +01:00
										 |  |  |         virtual ~IReporter(); | 
					
						
							| 
									
										
										
										
											2012-05-09 08:17:51 +01:00
										 |  |  |         virtual bool shouldRedirectStdout() const = 0;         | 
					
						
							|  |  |  |         virtual void StartTesting() = 0;         | 
					
						
							|  |  |  |         virtual void EndTesting( const Totals& totals ) = 0;         | 
					
						
							|  |  |  |         virtual void StartGroup( const std::string& groupName ) = 0;         | 
					
						
							|  |  |  |         virtual void EndGroup( const std::string& groupName, const Totals& totals ) = 0;         | 
					
						
							| 
									
										
										
										
											2012-08-31 08:10:36 +01:00
										 |  |  |         virtual void StartSection( const std::string& sectionName, const std::string& description ) = 0; | 
					
						
							|  |  |  |         virtual void NoAssertionsInSection( const std::string& sectionName ) = 0; | 
					
						
							|  |  |  |         virtual void NoAssertionsInTestCase( const std::string& testName ) = 0; | 
					
						
							|  |  |  |         virtual void EndSection( const std::string& sectionName, const Counts& assertions ) = 0; | 
					
						
							| 
									
										
										
										
											2012-05-09 08:17:51 +01:00
										 |  |  |         virtual void StartTestCase( const TestCaseInfo& testInfo ) = 0;         | 
					
						
							| 
									
										
										
										
											2012-06-01 19:40:27 +01:00
										 |  |  |         virtual void Aborted() = 0; | 
					
						
							|  |  |  |         virtual void EndTestCase( const TestCaseInfo& testInfo, const Totals& totals, const std::string& stdOut, const std::string& stdErr ) = 0; | 
					
						
							| 
									
										
										
										
											2012-05-09 08:17:51 +01:00
										 |  |  |         virtual void Result( const ResultInfo& result ) = 0; | 
					
						
							| 
									
										
										
										
											2010-12-31 22:07:47 +00:00
										 |  |  |     }; | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2012-05-09 08:17:51 +01:00
										 |  |  |     struct IReporterFactory { | 
					
						
							| 
									
										
										
										
											2012-08-13 07:46:10 +01:00
										 |  |  |         virtual ~IReporterFactory(); | 
					
						
							| 
									
										
										
										
											2012-07-20 19:07:42 +01:00
										 |  |  |         virtual IReporter* create( const ReporterConfig& config ) const = 0; | 
					
						
							| 
									
										
										
										
											2012-05-09 08:17:51 +01:00
										 |  |  |         virtual std::string getDescription() const = 0; | 
					
						
							| 
									
										
										
										
											2010-12-31 22:07:47 +00:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-09 08:17:51 +01:00
										 |  |  |     struct IReporterRegistry { | 
					
						
							| 
									
										
										
										
											2010-12-31 22:21:36 +00:00
										 |  |  |         typedef std::map<std::string, IReporterFactory*> FactoryMap; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-13 07:46:10 +01:00
										 |  |  |         virtual ~IReporterRegistry(); | 
					
						
							| 
									
										
										
										
											2012-07-20 19:07:42 +01:00
										 |  |  |         virtual IReporter* create( const std::string& name, const ReporterConfig& config ) const = 0;         | 
					
						
							| 
									
										
										
										
											2012-05-09 08:17:51 +01:00
										 |  |  |         virtual const FactoryMap& getFactories() const = 0; | 
					
						
							| 
									
										
										
										
											2010-12-31 22:07:47 +00:00
										 |  |  |     }; | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2012-05-15 08:02:36 +01:00
										 |  |  |     inline std::string trim( const std::string& str ) { | 
					
						
							| 
									
										
										
										
											2010-12-31 22:07:47 +00:00
										 |  |  |         std::string::size_type start = str.find_first_not_of( "\n\r\t " ); | 
					
						
							|  |  |  |         std::string::size_type end = str.find_last_not_of( "\n\r\t " ); | 
					
						
							|  |  |  |          | 
					
						
							| 
									
										
										
										
											2012-02-28 20:04:25 +00:00
										 |  |  |         return start != std::string::npos ? str.substr( start, 1+end-start ) : ""; | 
					
						
							| 
									
										
										
										
											2010-12-31 22:07:47 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-17 01:42:29 -04:00
										 |  |  | #endif // TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
 |