Catches incorrect reporter name as per #107

This commit is contained in:
Phil Nash 2012-07-28 20:37:07 +01:00
parent b084562b3b
commit 61756974d0
3 changed files with 27 additions and 5 deletions

View File

@ -36,6 +36,12 @@ namespace Catch {
Ptr<IReporter> reporter = getCurrentContext().getReporterRegistry().create( reporterName, reporterConfig ); Ptr<IReporter> reporter = getCurrentContext().getReporterRegistry().create( reporterName, reporterConfig );
if( !reporter )
{
std::cerr << "No reporter registered with name: " << reporterName << "'" << std::endl;
return (std::numeric_limits<int>::max)();
}
if( !config.data().stream.empty() ) { if( !config.data().stream.empty() ) {
if( config.data().stream[0] == '%' ) if( config.data().stream[0] == '%' )
config.useStream( config.data().stream.substr( 1 ) ); config.useStream( config.data().stream.substr( 1 ) );

View File

@ -20,10 +20,12 @@ namespace Catch {
public: public:
Ptr() : m_p( NULL ){} Ptr() : m_p( NULL ){}
Ptr( T* p ) : m_p( p ){ Ptr( T* p ) : m_p( p ){
m_p->addRef(); if( m_p )
m_p->addRef();
} }
Ptr( const Ptr& other ) : m_p( other.m_p ){ Ptr( const Ptr& other ) : m_p( other.m_p ){
m_p->addRef(); if( m_p )
m_p->addRef();
} }
~Ptr(){ ~Ptr(){
if( m_p ) if( m_p )
@ -63,6 +65,9 @@ namespace Catch {
const T* operator->() const{ const T* operator->() const{
return m_p; return m_p;
} }
bool operator !() const {
return m_p == NULL;
}
private: private:
T* m_p; T* m_p;

View File

@ -1,5 +1,5 @@
/* /*
* Generated: 2012-07-28 20:22:25.519628 * Generated: 2012-07-28 20:36:23.213113
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@ -196,10 +196,12 @@ namespace Catch {
public: public:
Ptr() : m_p( NULL ){} Ptr() : m_p( NULL ){}
Ptr( T* p ) : m_p( p ){ Ptr( T* p ) : m_p( p ){
m_p->addRef(); if( m_p )
m_p->addRef();
} }
Ptr( const Ptr& other ) : m_p( other.m_p ){ Ptr( const Ptr& other ) : m_p( other.m_p ){
m_p->addRef(); if( m_p )
m_p->addRef();
} }
~Ptr(){ ~Ptr(){
if( m_p ) if( m_p )
@ -239,6 +241,9 @@ namespace Catch {
const T* operator->() const{ const T* operator->() const{
return m_p; return m_p;
} }
bool operator !() const {
return m_p == NULL;
}
private: private:
T* m_p; T* m_p;
@ -4616,6 +4621,12 @@ namespace Catch {
Ptr<IReporter> reporter = getCurrentContext().getReporterRegistry().create( reporterName, reporterConfig ); Ptr<IReporter> reporter = getCurrentContext().getReporterRegistry().create( reporterName, reporterConfig );
if( !reporter )
{
std::cerr << "No reporter registered with name: " << reporterName << "'" << std::endl;
return (std::numeric_limits<int>::max)();
}
if( !config.data().stream.empty() ) { if( !config.data().stream.empty() ) {
if( config.data().stream[0] == '%' ) if( config.data().stream[0] == '%' )
config.useStream( config.data().stream.substr( 1 ) ); config.useStream( config.data().stream.substr( 1 ) );