Replace some static strings with static char*s for leak detection friendliness (h/t #272)
diff --git a/include/reporters/catch_reporter_console.hpp b/include/reporters/catch_reporter_console.hpp
index 71ca890..62c3568 100644
--- a/include/reporters/catch_reporter_console.hpp
+++ b/include/reporters/catch_reporter_console.hpp
@@ -256,7 +256,7 @@
m_atLeastOneTestCasePrinted = true;
}
void lazyPrintRunInfo() {
- stream << "\n" << getTildes() << "\n";
+ stream << "\n" << getLineOfChars<'~'>() << "\n";
Colour colour( Colour::SecondaryText );
stream << currentTestRunInfo->name
<< " is a Catch v" << libraryVersion.majorVersion << "."
@@ -292,19 +292,19 @@
SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
if( !lineInfo.empty() ){
- stream << getDashes() << "\n";
+ stream << getLineOfChars<'-'>() << "\n";
Colour colourGuard( Colour::FileName );
stream << lineInfo << "\n";
}
- stream << getDots() << "\n" << std::endl;
+ stream << getLineOfChars<'.'>() << "\n" << std::endl;
}
void printClosedHeader( std::string const& _name ) {
printOpenHeader( _name );
- stream << getDots() << "\n";
+ stream << getLineOfChars<'.'>() << "\n";
}
void printOpenHeader( std::string const& _name ) {
- stream << getDashes() << "\n";
+ stream << getLineOfChars<'-'>() << "\n";
{
Colour colourGuard( Colour::Headers );
printHeaderString( _name );
@@ -377,26 +377,19 @@
}
void printTotalsDivider() {
- stream << getDoubleDashes() << "\n";
+ stream << getLineOfChars<'='>() << "\n";
}
void printSummaryDivider() {
- stream << getDashes() << "\n";
+ stream << getLineOfChars<'-'>() << "\n";
}
- static std::string const& getDashes() {
- static const std::string dashes( CATCH_CONFIG_CONSOLE_WIDTH-1, '-' );
- return dashes;
- }
- static std::string const& getDots() {
- static const std::string dots( CATCH_CONFIG_CONSOLE_WIDTH-1, '.' );
- return dots;
- }
- 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;
+ template<char C>
+ static char const* getLineOfChars() {
+ static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0};
+ if( !*line ) {
+ memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 );
+ line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0;
+ }
+ return line;
}
private: