2010-12-31 17:07:47 -05:00
|
|
|
/*
|
2010-12-31 17:46:51 -05:00
|
|
|
* catch_interfaces_reporter.h
|
2010-12-31 17:07:47 -05:00
|
|
|
* Test
|
|
|
|
*
|
|
|
|
* 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 03:59:35 -05:00
|
|
|
#include "catch_totals.hpp"
|
2012-05-04 02:55:11 -04:00
|
|
|
#include "catch_ptr.hpp"
|
2010-12-31 17:07:47 -05:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <ostream>
|
2010-12-31 17:21:36 -05:00
|
|
|
#include <map>
|
2010-12-31 17:07:47 -05:00
|
|
|
|
|
|
|
namespace Catch
|
|
|
|
{
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
struct IReporterConfig
|
|
|
|
{
|
2011-01-31 05:10:20 -05:00
|
|
|
virtual ~IReporterConfig
|
|
|
|
()
|
|
|
|
{}
|
|
|
|
|
2010-12-31 17:07:47 -05:00
|
|
|
virtual std::ostream& stream
|
|
|
|
() const = 0;
|
|
|
|
|
|
|
|
virtual bool includeSuccessfulResults
|
|
|
|
() const = 0;
|
2011-04-12 03:07:39 -04:00
|
|
|
|
|
|
|
virtual std::string getName
|
|
|
|
() const = 0;
|
2010-12-31 17:07:47 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class TestCaseInfo;
|
|
|
|
class ResultInfo;
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2012-05-04 02:55:11 -04:00
|
|
|
struct IReporter : IShared
|
2010-12-31 17:07:47 -05:00
|
|
|
{
|
|
|
|
virtual ~IReporter
|
|
|
|
(){}
|
|
|
|
|
2012-02-17 04:28:21 -05:00
|
|
|
virtual bool shouldRedirectStdout
|
|
|
|
() const = 0;
|
|
|
|
|
2010-12-31 17:07:47 -05:00
|
|
|
virtual void StartTesting
|
|
|
|
() = 0;
|
|
|
|
|
|
|
|
virtual void EndTesting
|
2012-02-24 03:59:35 -05:00
|
|
|
( const Totals& totals
|
2010-12-31 17:07:47 -05:00
|
|
|
) = 0;
|
|
|
|
|
|
|
|
virtual void StartGroup
|
|
|
|
( const std::string& groupName
|
|
|
|
) = 0;
|
|
|
|
|
|
|
|
virtual void EndGroup
|
|
|
|
( const std::string& groupName,
|
2012-02-24 03:59:35 -05:00
|
|
|
const Totals& totals
|
2010-12-31 17:07:47 -05:00
|
|
|
) = 0;
|
|
|
|
|
|
|
|
virtual void StartSection
|
|
|
|
( const std::string& sectionName,
|
|
|
|
const std::string description
|
|
|
|
) = 0;
|
|
|
|
|
|
|
|
virtual void EndSection
|
|
|
|
( const std::string& sectionName,
|
2012-02-24 03:59:35 -05:00
|
|
|
const Counts& assertions
|
2010-12-31 17:07:47 -05:00
|
|
|
) = 0;
|
|
|
|
|
|
|
|
virtual void StartTestCase
|
|
|
|
( const TestCaseInfo& testInfo
|
|
|
|
) = 0;
|
|
|
|
|
|
|
|
virtual void EndTestCase
|
|
|
|
( const TestCaseInfo& testInfo,
|
2012-02-24 03:59:35 -05:00
|
|
|
const Totals& totals,
|
2010-12-31 17:07:47 -05:00
|
|
|
const std::string& stdOut,
|
|
|
|
const std::string& stdErr
|
|
|
|
) = 0;
|
|
|
|
|
|
|
|
virtual void Result
|
|
|
|
( const ResultInfo& result
|
|
|
|
) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
struct IReporterFactory
|
|
|
|
{
|
|
|
|
virtual ~IReporterFactory
|
|
|
|
(){}
|
|
|
|
|
|
|
|
virtual IReporter* create
|
|
|
|
( const IReporterConfig& config
|
|
|
|
) const = 0;
|
|
|
|
|
|
|
|
virtual std::string getDescription
|
|
|
|
() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
struct IReporterRegistry
|
|
|
|
{
|
2010-12-31 17:21:36 -05:00
|
|
|
typedef std::map<std::string, IReporterFactory*> FactoryMap;
|
|
|
|
|
2010-12-31 17:07:47 -05:00
|
|
|
virtual ~IReporterRegistry
|
|
|
|
(){}
|
|
|
|
|
|
|
|
virtual IReporter* create
|
|
|
|
( const std::string& name,
|
|
|
|
const IReporterConfig& config
|
|
|
|
) const = 0;
|
|
|
|
|
|
|
|
virtual void registerReporter
|
|
|
|
( const std::string& name,
|
|
|
|
IReporterFactory* factory
|
2010-12-31 17:21:36 -05:00
|
|
|
) = 0;
|
|
|
|
|
|
|
|
virtual const FactoryMap& getFactories
|
|
|
|
() const = 0;
|
|
|
|
|
2010-12-31 17:07:47 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
inline std::string trim( const std::string& str )
|
|
|
|
{
|
|
|
|
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 15:04:25 -05:00
|
|
|
return start != std::string::npos ? str.substr( start, 1+end-start ) : "";
|
2010-12-31 17:07:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TWOBLUECUBES_CATCH_IREPORTERREGISTRY_INCLUDED
|