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)
|
|
|
|
*/
|
2012-09-17 07:42:29 +02:00
|
|
|
#ifndef TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
|
2010-12-31 23:07:47 +01:00
|
|
|
|
|
|
|
#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
|
|
|
{}
|
|
|
|
|
2012-09-20 09:17:52 +02:00
|
|
|
ReporterConfig( const ReporterConfig& other )
|
|
|
|
: name( other.name ),
|
|
|
|
stream( other.stream ),
|
|
|
|
includeSuccessfulResults( other.includeSuccessfulResults ),
|
|
|
|
fullConfig( other.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;
|
2012-09-20 09:17:52 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void operator=(const ReporterConfig&);
|
2012-08-28 09:20:18 +02:00
|
|
|
};
|
2010-12-31 23:07:47 +01:00
|
|
|
|
|
|
|
class TestCaseInfo;
|
2012-11-01 09:27:09 +01:00
|
|
|
class AssertionResult;
|
2010-12-31 23:07:47 +01:00
|
|
|
|
2012-05-09 09:17:51 +02:00
|
|
|
struct IReporter : IShared {
|
2012-08-13 08:46:10 +02:00
|
|
|
virtual ~IReporter();
|
2012-11-01 09:27:09 +01:00
|
|
|
|
|
|
|
virtual bool shouldRedirectStdout() const = 0;
|
|
|
|
|
2012-05-09 09:17:51 +02:00
|
|
|
virtual void StartTesting() = 0;
|
|
|
|
virtual void EndTesting( const Totals& totals ) = 0;
|
2012-11-01 09:27:09 +01:00
|
|
|
|
|
|
|
virtual void StartGroup( const std::string& groupName ) = 0;
|
2012-05-09 09:17:51 +02:00
|
|
|
virtual void EndGroup( const std::string& groupName, const Totals& totals ) = 0;
|
2012-11-01 09:27:09 +01:00
|
|
|
|
|
|
|
virtual void StartTestCase( const TestCaseInfo& testInfo ) = 0;
|
|
|
|
// TestCaseResult
|
|
|
|
virtual void EndTestCase( const TestCaseInfo& testInfo, const Totals& totals, const std::string& stdOut, const std::string& stdErr ) = 0;
|
|
|
|
|
|
|
|
// SectionInfo
|
2012-08-31 09:10:36 +02:00
|
|
|
virtual void StartSection( const std::string& sectionName, const std::string& description ) = 0;
|
2012-11-01 09:27:09 +01:00
|
|
|
// Section Result
|
|
|
|
virtual void EndSection( const std::string& sectionName, const Counts& assertions ) = 0;
|
|
|
|
|
|
|
|
// - merge into SectionResult ?
|
2012-08-31 09:10:36 +02:00
|
|
|
virtual void NoAssertionsInSection( const std::string& sectionName ) = 0;
|
|
|
|
virtual void NoAssertionsInTestCase( const std::string& testName ) = 0;
|
2012-11-01 09:27:09 +01:00
|
|
|
|
|
|
|
// - merge into SectionResult, TestCaseResult, GroupResult & TestRunResult
|
2012-06-01 20:40:27 +02:00
|
|
|
virtual void Aborted() = 0;
|
2012-11-01 09:27:09 +01:00
|
|
|
|
|
|
|
// AssertionReslt
|
|
|
|
virtual void Result( const AssertionResult& 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-17 07:42:29 +02:00
|
|
|
#endif // TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
|