Moar reformatting

This commit is contained in:
Phil Nash
2012-05-15 23:58:23 +01:00
parent d0be9ed5d9
commit c67a7eef2b
8 changed files with 140 additions and 429 deletions

View File

@@ -1,15 +1,10 @@
/*
* catch_config.hpp
* Catch
*
* Created by Phil on 08/11/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_RUNNERCONFIG_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_RUNNERCONFIG_HPP_INCLUDED
@@ -21,24 +16,20 @@
#include <string>
#include <iostream>
namespace Catch
{
class Config : public IReporterConfig
{
namespace Catch {
class Config : public IReporterConfig {
private:
Config( const Config& other );
Config& operator = ( const Config& other );
public:
struct Include { enum What
{
struct Include { enum What {
FailedOnly,
SuccessfulResults
}; };
struct List{ enum What
{
struct List{ enum What {
None = 0,
Reports = 1,
@@ -54,7 +45,6 @@ namespace Catch
}; };
///////////////////////////////////////////////////////////////////////////
Config()
: m_listSpec( List::None ),
m_shouldDebugBreak( false ),
@@ -64,167 +54,115 @@ namespace Catch
m_includeWhat( Include::FailedOnly )
{}
///////////////////////////////////////////////////////////////////////////
~Config()
{
~Config() {
m_os.rdbuf( std::cout.rdbuf() );
delete m_streambuf;
}
///////////////////////////////////////////////////////////////////////////
void setReporter( const std::string& reporterName )
{
void setReporter( const std::string& reporterName ) {
if( m_reporter.get() )
return setError( "Only one reporter may be specified" );
setReporter( Context::getReporterRegistry().create( reporterName, *this ) );
}
///////////////////////////////////////////////////////////////////////////
void addTestSpec( const std::string& testSpec )
{
void addTestSpec( const std::string& testSpec ) {
m_testSpecs.push_back( testSpec );
}
///////////////////////////////////////////////////////////////////////////
bool testsSpecified() const
{
bool testsSpecified() const {
return !m_testSpecs.empty();
}
///////////////////////////////////////////////////////////////////////////
const std::vector<std::string>& getTestSpecs() const
{
const std::vector<std::string>& getTestSpecs() const {
return m_testSpecs;
}
///////////////////////////////////////////////////////////////////////////
List::What getListSpec( void ) const
{
List::What getListSpec( void ) const {
return m_listSpec;
}
///////////////////////////////////////////////////////////////////////////
void setListSpec( List::What listSpec )
{
void setListSpec( List::What listSpec ) {
m_listSpec = listSpec;
}
///////////////////////////////////////////////////////////////////////////
void setFilename( const std::string& filename )
{
void setFilename( const std::string& filename ) {
m_filename = filename;
}
///////////////////////////////////////////////////////////////////////////
const std::string& getFilename() const
{
const std::string& getFilename() const {
return m_filename;
}
///////////////////////////////////////////////////////////////////////////
const std::string& getMessage() const
{
const std::string& getMessage() const {
return m_message;
}
///////////////////////////////////////////////////////////////////////////
void setError( const std::string& errorMessage )
{
void setError( const std::string& errorMessage ) {
m_message = errorMessage + "\n\n" + "Usage: ...";
}
///////////////////////////////////////////////////////////////////////////
void setReporter( IReporter* reporter )
{
void setReporter( IReporter* reporter ) {
m_reporter = reporter;
}
///////////////////////////////////////////////////////////////////////////
Ptr<IReporter> getReporter()
{
Ptr<IReporter> getReporter() {
if( !m_reporter.get() )
const_cast<Config*>( this )->setReporter( Context::getReporterRegistry().create( "basic", *this ) );
return m_reporter;
}
///////////////////////////////////////////////////////////////////////////
List::What listWhat() const
{
List::What listWhat() const {
return static_cast<List::What>( m_listSpec & List::WhatMask );
}
///////////////////////////////////////////////////////////////////////////
List::What listAs() const
{
List::What listAs() const {
return static_cast<List::What>( m_listSpec & List::AsMask );
}
///////////////////////////////////////////////////////////////////////////
void setIncludeWhat( Include::What includeWhat )
{
void setIncludeWhat( Include::What includeWhat ) {
m_includeWhat = includeWhat;
}
///////////////////////////////////////////////////////////////////////////
void setShouldDebugBreak( bool shouldDebugBreakFlag )
{
void setShouldDebugBreak( bool shouldDebugBreakFlag ) {
m_shouldDebugBreak = shouldDebugBreakFlag;
}
///////////////////////////////////////////////////////////////////////////
void setName( const std::string& name )
{
void setName( const std::string& name ) {
m_name = name;
}
///////////////////////////////////////////////////////////////////////////
std::string getName() const
{
std::string getName() const {
return m_name;
}
///////////////////////////////////////////////////////////////////////////
bool shouldDebugBreak() const
{
bool shouldDebugBreak() const {
return m_shouldDebugBreak;
}
///////////////////////////////////////////////////////////////////////////
void setShowHelp( bool showHelpFlag )
{
void setShowHelp( bool showHelpFlag ) {
m_showHelp = showHelpFlag;
}
///////////////////////////////////////////////////////////////////////////
bool showHelp() const
{
bool showHelp() const {
return m_showHelp;
}
///////////////////////////////////////////////////////////////////////////
virtual std::ostream& stream() const
{
virtual std::ostream& stream() const {
return m_os;
}
///////////////////////////////////////////////////////////////////////////
void setStreamBuf( std::streambuf* buf )
{
void setStreamBuf( std::streambuf* buf ) {
m_os.rdbuf( buf ? buf : std::cout.rdbuf() );
}
///////////////////////////////////////////////////////////////////////////
void useStream( const std::string& streamName )
{
void useStream( const std::string& streamName ) {
std::streambuf* newBuf = Context::createStreamBuf( streamName );
setStreamBuf( newBuf );
delete m_streambuf;
m_streambuf = newBuf;
}
///////////////////////////////////////////////////////////////////////////
virtual bool includeSuccessfulResults() const
{
virtual bool includeSuccessfulResults() const {
return m_includeWhat == Include::SuccessfulResults;
}