Replace some static strings with static char*s for leak detection friendliness (h/t #272)

This commit is contained in:
Phil Nash 2014-04-22 17:54:29 +01:00
parent 48153e8e10
commit f219194199

View File

@ -256,7 +256,7 @@ namespace Catch {
m_atLeastOneTestCasePrinted = true; m_atLeastOneTestCasePrinted = true;
} }
void lazyPrintRunInfo() { void lazyPrintRunInfo() {
stream << "\n" << getTildes() << "\n"; stream << "\n" << getLineOfChars<'~'>() << "\n";
Colour colour( Colour::SecondaryText ); Colour colour( Colour::SecondaryText );
stream << currentTestRunInfo->name stream << currentTestRunInfo->name
<< " is a Catch v" << libraryVersion.majorVersion << "." << " is a Catch v" << libraryVersion.majorVersion << "."
@ -292,19 +292,19 @@ namespace Catch {
SourceLineInfo lineInfo = m_sectionStack.front().lineInfo; SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
if( !lineInfo.empty() ){ if( !lineInfo.empty() ){
stream << getDashes() << "\n"; stream << getLineOfChars<'-'>() << "\n";
Colour colourGuard( Colour::FileName ); Colour colourGuard( Colour::FileName );
stream << lineInfo << "\n"; stream << lineInfo << "\n";
} }
stream << getDots() << "\n" << std::endl; stream << getLineOfChars<'.'>() << "\n" << std::endl;
} }
void printClosedHeader( std::string const& _name ) { void printClosedHeader( std::string const& _name ) {
printOpenHeader( _name ); printOpenHeader( _name );
stream << getDots() << "\n"; stream << getLineOfChars<'.'>() << "\n";
} }
void printOpenHeader( std::string const& _name ) { void printOpenHeader( std::string const& _name ) {
stream << getDashes() << "\n"; stream << getLineOfChars<'-'>() << "\n";
{ {
Colour colourGuard( Colour::Headers ); Colour colourGuard( Colour::Headers );
printHeaderString( _name ); printHeaderString( _name );
@ -377,26 +377,19 @@ namespace Catch {
} }
void printTotalsDivider() { void printTotalsDivider() {
stream << getDoubleDashes() << "\n"; stream << getLineOfChars<'='>() << "\n";
} }
void printSummaryDivider() { void printSummaryDivider() {
stream << getDashes() << "\n"; stream << getLineOfChars<'-'>() << "\n";
} }
static std::string const& getDashes() { template<char C>
static const std::string dashes( CATCH_CONFIG_CONSOLE_WIDTH-1, '-' ); static char const* getLineOfChars() {
return dashes; static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0};
} if( !*line ) {
static std::string const& getDots() { memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 );
static const std::string dots( CATCH_CONFIG_CONSOLE_WIDTH-1, '.' ); line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0;
return dots; }
} return line;
static std::string const& getDoubleDashes() {
static const std::string doubleDashes( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' );
return doubleDashes;
}
static std::string const& getTildes() {
static const std::string dots( CATCH_CONFIG_CONSOLE_WIDTH-1, '~' );
return dots;
} }
private: private: