Only use std::cout/ cert via Catch::cout/ cert - and make those conditional on CATCH_CONFIG_NOSTDOUT

This commit is contained in:
Phil Nash
2014-10-02 19:08:19 +01:00
parent 85b4e94192
commit 383d7c06a1
15 changed files with 109 additions and 83 deletions

View File

@@ -108,7 +108,7 @@ namespace Catch {
: m_cli( makeCommandLineParser() ) {
if( alreadyInstantiated ) {
std::string msg = "Only one instance of Catch::Session can ever be used";
std::cerr << msg << std::endl;
Catch::cerr() << msg << std::endl;
throw std::logic_error( msg );
}
alreadyInstantiated = true;
@@ -118,15 +118,15 @@ namespace Catch {
}
void showHelp( std::string const& processName ) {
std::cout << "\nCatch v" << libraryVersion.majorVersion << "."
Catch::cout() << "\nCatch v" << libraryVersion.majorVersion << "."
<< libraryVersion.minorVersion << " build "
<< libraryVersion.buildNumber;
if( libraryVersion.branchName != std::string( "master" ) )
std::cout << " (" << libraryVersion.branchName << " branch)";
std::cout << "\n";
Catch::cout() << " (" << libraryVersion.branchName << " branch)";
Catch::cout() << "\n";
m_cli.usage( std::cout, processName );
std::cout << "For more detail usage please see the project docs\n" << std::endl;
m_cli.usage( Catch::cout(), processName );
Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
}
int applyCommandLine( int argc, char* const argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
@@ -140,11 +140,11 @@ namespace Catch {
catch( std::exception& ex ) {
{
Colour colourGuard( Colour::Red );
std::cerr << "\nError(s) in input:\n"
Catch::cerr() << "\nError(s) in input:\n"
<< Text( ex.what(), TextAttributes().setIndent(2) )
<< "\n\n";
}
m_cli.usage( std::cout, m_configData.processName );
m_cli.usage( Catch::cout(), m_configData.processName );
return (std::numeric_limits<int>::max)();
}
return 0;
@@ -182,7 +182,7 @@ namespace Catch {
return static_cast<int>( runner.runTests().assertions.failed );
}
catch( std::exception& ex ) {
std::cerr << ex.what() << std::endl;
Catch::cerr() << ex.what() << std::endl;
return (std::numeric_limits<int>::max)();
}
}