2010-12-31 23:07:47 +01: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)
|
|
|
|
*/
|
|
|
|
#ifndef TWOBLUECUBES_CATCH_IREPORTERREGISTRY_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_IREPORTERREGISTRY_INCLUDED
|
|
|
|
|
|
|
|
#include "catch_common.h"
|
2012-02-24 09:59:35 +01:00
|
|
|
#include "catch_totals.hpp"
|
2012-05-04 08:55:11 +02:00
|
|
|
#include "catch_ptr.hpp"
|
2012-08-28 09:20:18 +02:00
|
|
|
#include "catch_config.hpp"
|
2010-12-31 23:07:47 +01:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <ostream>
|
2010-12-31 23:21:36 +01:00
|
|
|
#include <map>
|
2010-12-31 23:07:47 +01:00
|
|
|
|
|
|
|
namespace Catch
|
|
|
|
{
|
2012-07-20 20:07:42 +02:00
|
|
|
struct ReporterConfig
|
|
|
|
{
|
|
|
|
ReporterConfig( const std::string& _name,
|
|
|
|
std::ostream& _stream,
|
2012-08-28 09:20:18 +02:00
|
|
|
bool _includeSuccessfulResults,
|
|
|
|
const ConfigData& _fullConfig )
|
2012-07-20 20:07:42 +02:00
|
|
|
: name( _name ),
|
|
|
|
stream( _stream ),
|
2012-08-28 09:20:18 +02:00
|
|
|
includeSuccessfulResults( _includeSuccessfulResults ),
|
|
|
|
fullConfig( _fullConfig )
|
2012-07-20 20:07:42 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
std::ostream& stream;
|
|
|
|
bool includeSuccessfulResults;
|
2012-08-28 09:20:18 +02:00
|
|
|
ConfigData fullConfig;
|
|
|
|
};
|
2010-12-31 23:07:47 +01:00
|
|
|
|
|
|
|
class TestCaseInfo;
|
|
|
|
class ResultInfo;
|
|
|
|
|
2012-05-09 09:17:51 +02:00
|
|
|
struct IReporter : IShared {
|
2012-08-13 08:46:10 +02:00
|
|
|
virtual ~IReporter();
|
2012-05-09 09:17:51 +02: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-05-16 15:53:59 +02:00
|
|
|
virtual void StartSection( const std::string& sectionName, const std::string& description ) = 0;
|
2012-05-09 09:17:51 +02:00
|
|
|
virtual void EndSection( const std::string& sectionName, const Counts& assertions ) = 0;
|
|
|
|
virtual void StartTestCase( const TestCaseInfo& testInfo ) = 0;
|
2012-06-01 20:40:27 +02: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 09:17:51 +02:00
|
|
|
virtual void Result( const ResultInfo& result ) = 0;
|
2010-12-31 23:07:47 +01:00
|
|
|
};
|
|
|
|
|
2012-05-09 09:17:51 +02:00
|
|
|
struct IReporterFactory {
|
2012-08-13 08:46:10 +02:00
|
|
|
virtual ~IReporterFactory();
|
2012-07-20 20:07:42 +02:00
|
|
|
virtual IReporter* create( const ReporterConfig& config ) const = 0;
|
2012-05-09 09:17:51 +02:00
|
|
|
virtual std::string getDescription() const = 0;
|
2010-12-31 23:07:47 +01:00
|
|
|
};
|
|
|
|
|
2012-05-09 09:17:51 +02:00
|
|
|
struct IReporterRegistry {
|
2010-12-31 23:21:36 +01:00
|
|
|
typedef std::map<std::string, IReporterFactory*> FactoryMap;
|
|
|
|
|
2012-08-13 08:46:10 +02:00
|
|
|
virtual ~IReporterRegistry();
|
2012-07-20 20:07:42 +02:00
|
|
|
virtual IReporter* create( const std::string& name, const ReporterConfig& config ) const = 0;
|
2012-05-09 09:17:51 +02:00
|
|
|
virtual const FactoryMap& getFactories() const = 0;
|
2010-12-31 23:07:47 +01:00
|
|
|
};
|
|
|
|
|
2012-05-15 09:02:36 +02:00
|
|
|
inline std::string trim( const std::string& str ) {
|
2010-12-31 23:07:47 +01: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 21:04:25 +01:00
|
|
|
return start != std::string::npos ? str.substr( start, 1+end-start ) : "";
|
2010-12-31 23:07:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TWOBLUECUBES_CATCH_IREPORTERREGISTRY_INCLUDED
|