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,9 +20,11 @@ namespace Catch {
public: public:
Ptr() : m_p( NULL ){} Ptr() : m_p( NULL ){}
Ptr( T* p ) : m_p( p ){ Ptr( T* p ) : m_p( p ){
if( m_p )
m_p->addRef(); m_p->addRef();
} }
Ptr( const Ptr& other ) : m_p( other.m_p ){ Ptr( const Ptr& other ) : m_p( other.m_p ){
if( m_p )
m_p->addRef(); m_p->addRef();
} }
~Ptr(){ ~Ptr(){
@ -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,9 +196,11 @@ namespace Catch {
public: public:
Ptr() : m_p( NULL ){} Ptr() : m_p( NULL ){}
Ptr( T* p ) : m_p( p ){ Ptr( T* p ) : m_p( p ){
if( m_p )
m_p->addRef(); m_p->addRef();
} }
Ptr( const Ptr& other ) : m_p( other.m_p ){ Ptr( const Ptr& other ) : m_p( other.m_p ){
if( m_p )
m_p->addRef(); m_p->addRef();
} }
~Ptr(){ ~Ptr(){
@ -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 ) );