mirror of https://github.com/catchorg/Catch2.git
Replace std::endl with \n and flush
In some places the `std::flush` was not added, as it was sufficiently obvious that the flush semantics are not intended. There are likely other places where the flush semantics aren't intended, but that is a cleanup for later.
This commit is contained in:
parent
2ae28fc852
commit
c9027375a3
|
@ -161,16 +161,16 @@ namespace Catch {
|
||||||
|
|
||||||
void Session::showHelp() const {
|
void Session::showHelp() const {
|
||||||
Catch::cout()
|
Catch::cout()
|
||||||
<< "\nCatch v" << libraryVersion() << "\n"
|
<< "\nCatch v" << libraryVersion() << '\n'
|
||||||
<< m_cli << std::endl
|
<< m_cli << '\n'
|
||||||
<< "For more detailed usage please see the project docs\n" << std::endl;
|
<< "For more detailed usage please see the project docs\n\n" << std::flush;
|
||||||
}
|
}
|
||||||
void Session::libIdentify() {
|
void Session::libIdentify() {
|
||||||
Catch::cout()
|
Catch::cout()
|
||||||
<< std::left << std::setw(16) << "description: " << "A Catch2 test executable\n"
|
<< std::left << std::setw(16) << "description: " << "A Catch2 test executable\n"
|
||||||
<< std::left << std::setw(16) << "category: " << "testframework\n"
|
<< std::left << std::setw(16) << "category: " << "testframework\n"
|
||||||
<< std::left << std::setw(16) << "framework: " << "Catch Test\n"
|
<< std::left << std::setw(16) << "framework: " << "Catch Test\n"
|
||||||
<< std::left << std::setw(16) << "version: " << libraryVersion() << std::endl;
|
<< std::left << std::setw(16) << "version: " << libraryVersion() << '\n' << std::flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Session::applyCommandLine( int argc, char const * const * argv ) {
|
int Session::applyCommandLine( int argc, char const * const * argv ) {
|
||||||
|
@ -186,7 +186,7 @@ namespace Catch {
|
||||||
<< "\nError(s) in input:\n"
|
<< "\nError(s) in input:\n"
|
||||||
<< TextFlow::Column( result.errorMessage() ).indent( 2 )
|
<< TextFlow::Column( result.errorMessage() ).indent( 2 )
|
||||||
<< "\n\n";
|
<< "\n\n";
|
||||||
Catch::cerr() << "Run with -? for usage\n" << std::endl;
|
Catch::cerr() << "Run with -? for usage\n\n" << std::flush;
|
||||||
return MaxExitCode;
|
return MaxExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,12 +229,12 @@ namespace Catch {
|
||||||
|
|
||||||
int Session::run() {
|
int Session::run() {
|
||||||
if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeStart ) != 0 ) {
|
if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeStart ) != 0 ) {
|
||||||
Catch::cout() << "...waiting for enter/ return before starting" << std::endl;
|
Catch::cout() << "...waiting for enter/ return before starting\n" << std::flush;
|
||||||
static_cast<void>(std::getchar());
|
static_cast<void>(std::getchar());
|
||||||
}
|
}
|
||||||
int exitCode = runInternal();
|
int exitCode = runInternal();
|
||||||
if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeExit ) != 0 ) {
|
if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeExit ) != 0 ) {
|
||||||
Catch::cout() << "...waiting for enter/ return before exiting, with code: " << exitCode << std::endl;
|
Catch::cout() << "...waiting for enter/ return before exiting, with code: " << exitCode << '\n' << std::flush;
|
||||||
static_cast<void>(std::getchar());
|
static_cast<void>(std::getchar());
|
||||||
}
|
}
|
||||||
return exitCode;
|
return exitCode;
|
||||||
|
@ -296,7 +296,7 @@ namespace Catch {
|
||||||
}
|
}
|
||||||
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
|
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
|
||||||
catch( std::exception& ex ) {
|
catch( std::exception& ex ) {
|
||||||
Catch::cerr() << ex.what() << std::endl;
|
Catch::cerr() << ex.what() << '\n' << std::flush;
|
||||||
return MaxExitCode;
|
return MaxExitCode;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
size = sizeof(info);
|
size = sizeof(info);
|
||||||
if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0) != 0 ) {
|
if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0) != 0 ) {
|
||||||
Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl;
|
Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n\n" << std::flush;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -329,7 +329,7 @@ namespace {
|
||||||
|
|
||||||
void XmlWriter::newlineIfNecessary() {
|
void XmlWriter::newlineIfNecessary() {
|
||||||
if( m_needsNewline ) {
|
if( m_needsNewline ) {
|
||||||
m_os << std::endl;
|
m_os << '\n' << std::flush;
|
||||||
m_needsNewline = false;
|
m_needsNewline = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ namespace Catch {
|
||||||
.width( CATCH_CONFIG_CONSOLE_WIDTH - 10 );
|
.width( CATCH_CONFIG_CONSOLE_WIDTH - 10 );
|
||||||
out << str << wrapper << '\n';
|
out << str << wrapper << '\n';
|
||||||
}
|
}
|
||||||
out << pluralise( tags.size(), "tag" ) << '\n' << std::endl;
|
out << pluralise(tags.size(), "tag") << "\n\n" << std::flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
void defaultListTests(std::ostream& out, std::vector<TestCaseHandle> const& tests, bool isFiltered, Verbosity verbosity) {
|
void defaultListTests(std::ostream& out, std::vector<TestCaseHandle> const& tests, bool isFiltered, Verbosity verbosity) {
|
||||||
|
@ -196,7 +196,7 @@ namespace Catch {
|
||||||
|
|
||||||
out << TextFlow::Column(testCaseInfo.name).initialIndent(2).indent(4) << '\n';
|
out << TextFlow::Column(testCaseInfo.name).initialIndent(2).indent(4) << '\n';
|
||||||
if (verbosity >= Verbosity::High) {
|
if (verbosity >= Verbosity::High) {
|
||||||
out << TextFlow::Column(Catch::Detail::stringify(testCaseInfo.lineInfo)).indent(4) << std::endl;
|
out << TextFlow::Column(Catch::Detail::stringify(testCaseInfo.lineInfo)).indent(4) << '\n' << std::flush;
|
||||||
}
|
}
|
||||||
if (!testCaseInfo.tags.empty() &&
|
if (!testCaseInfo.tags.empty() &&
|
||||||
verbosity > Verbosity::Quiet) {
|
verbosity > Verbosity::Quiet) {
|
||||||
|
@ -205,9 +205,9 @@ namespace Catch {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFiltered) {
|
if (isFiltered) {
|
||||||
out << pluralise(tests.size(), "matching test case") << '\n' << std::endl;
|
out << pluralise(tests.size(), "matching test case") << "\n\n" << std::flush;
|
||||||
} else {
|
} else {
|
||||||
out << pluralise(tests.size(), "test case") << '\n' << std::endl;
|
out << pluralise(tests.size(), "test case") << "\n\n" << std::flush;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -259,7 +259,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompactReporter::noMatchingTestCases( std::string const& spec ) {
|
void CompactReporter::noMatchingTestCases( std::string const& spec ) {
|
||||||
stream << "No test cases matched '" << spec << '\'' << std::endl;
|
stream << "No test cases matched '" << spec << "'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompactReporter::assertionStarting( AssertionInfo const& ) {}
|
void CompactReporter::assertionStarting( AssertionInfo const& ) {}
|
||||||
|
@ -279,20 +279,20 @@ private:
|
||||||
AssertionPrinter printer( stream, _assertionStats, printInfoMessages );
|
AssertionPrinter printer( stream, _assertionStats, printInfoMessages );
|
||||||
printer.print();
|
printer.print();
|
||||||
|
|
||||||
stream << std::endl;
|
stream << '\n' << std::flush;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompactReporter::sectionEnded(SectionStats const& _sectionStats) {
|
void CompactReporter::sectionEnded(SectionStats const& _sectionStats) {
|
||||||
double dur = _sectionStats.durationInSeconds;
|
double dur = _sectionStats.durationInSeconds;
|
||||||
if ( shouldShowDuration( *m_config, dur ) ) {
|
if ( shouldShowDuration( *m_config, dur ) ) {
|
||||||
stream << getFormattedDuration( dur ) << " s: " << _sectionStats.sectionInfo.name << std::endl;
|
stream << getFormattedDuration( dur ) << " s: " << _sectionStats.sectionInfo.name << '\n' << std::flush;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompactReporter::testRunEnded( TestRunStats const& _testRunStats ) {
|
void CompactReporter::testRunEnded( TestRunStats const& _testRunStats ) {
|
||||||
printTotals( stream, _testRunStats.totals );
|
printTotals( stream, _testRunStats.totals );
|
||||||
stream << '\n' << std::endl;
|
stream << "\n\n" << std::flush;
|
||||||
StreamingReporterBase::testRunEnded( _testRunStats );
|
StreamingReporterBase::testRunEnded( _testRunStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ public:
|
||||||
void close() {
|
void close() {
|
||||||
if (m_isOpen) {
|
if (m_isOpen) {
|
||||||
*this << RowBreak();
|
*this << RowBreak();
|
||||||
m_os << std::endl;
|
m_os << '\n' << std::flush;
|
||||||
m_isOpen = false;
|
m_isOpen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,11 +382,11 @@ std::string ConsoleReporter::getDescription() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleReporter::noMatchingTestCases(std::string const& spec) {
|
void ConsoleReporter::noMatchingTestCases(std::string const& spec) {
|
||||||
stream << "No test cases matched '" << spec << '\'' << std::endl;
|
stream << "No test cases matched '" << spec << "'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleReporter::reportInvalidArguments(std::string const& arg) {
|
void ConsoleReporter::reportInvalidArguments(std::string const& arg) {
|
||||||
stream << "Invalid Filter: " << arg << std::endl;
|
stream << "Invalid Filter: " << arg << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleReporter::assertionStarting(AssertionInfo const&) {}
|
void ConsoleReporter::assertionStarting(AssertionInfo const&) {}
|
||||||
|
@ -404,7 +404,7 @@ bool ConsoleReporter::assertionEnded(AssertionStats const& _assertionStats) {
|
||||||
|
|
||||||
ConsoleAssertionPrinter printer(stream, _assertionStats, includeResults);
|
ConsoleAssertionPrinter printer(stream, _assertionStats, includeResults);
|
||||||
printer.print();
|
printer.print();
|
||||||
stream << std::endl;
|
stream << '\n' << std::flush;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,11 +422,11 @@ void ConsoleReporter::sectionEnded(SectionStats const& _sectionStats) {
|
||||||
stream << "\nNo assertions in section";
|
stream << "\nNo assertions in section";
|
||||||
else
|
else
|
||||||
stream << "\nNo assertions in test case";
|
stream << "\nNo assertions in test case";
|
||||||
stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
|
stream << " '" << _sectionStats.sectionInfo.name << "'\n\n" << std::flush;
|
||||||
}
|
}
|
||||||
double dur = _sectionStats.durationInSeconds;
|
double dur = _sectionStats.durationInSeconds;
|
||||||
if (shouldShowDuration(*m_config, dur)) {
|
if (shouldShowDuration(*m_config, dur)) {
|
||||||
stream << getFormattedDuration(dur) << " s: " << _sectionStats.sectionInfo.name << std::endl;
|
stream << getFormattedDuration(dur) << " s: " << _sectionStats.sectionInfo.name << '\n' << std::flush;
|
||||||
}
|
}
|
||||||
if (m_headerPrinted) {
|
if (m_headerPrinted) {
|
||||||
m_headerPrinted = false;
|
m_headerPrinted = false;
|
||||||
|
@ -490,14 +490,14 @@ void ConsoleReporter::testGroupEnded(TestGroupStats const& _testGroupStats) {
|
||||||
printSummaryDivider();
|
printSummaryDivider();
|
||||||
stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
|
stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
|
||||||
printTotals(_testGroupStats.totals);
|
printTotals(_testGroupStats.totals);
|
||||||
stream << '\n' << std::endl;
|
stream << "\n\n" << std::flush;
|
||||||
}
|
}
|
||||||
StreamingReporterBase::testGroupEnded(_testGroupStats);
|
StreamingReporterBase::testGroupEnded(_testGroupStats);
|
||||||
}
|
}
|
||||||
void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) {
|
void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) {
|
||||||
printTotalsDivider(_testRunStats.totals);
|
printTotalsDivider(_testRunStats.totals);
|
||||||
printTotals(_testRunStats.totals);
|
printTotals(_testRunStats.totals);
|
||||||
stream << std::endl;
|
stream << '\n' << std::flush;
|
||||||
StreamingReporterBase::testRunEnded(_testRunStats);
|
StreamingReporterBase::testRunEnded(_testRunStats);
|
||||||
}
|
}
|
||||||
void ConsoleReporter::testRunStarting(TestRunInfo const& _testInfo) {
|
void ConsoleReporter::testRunStarting(TestRunInfo const& _testInfo) {
|
||||||
|
@ -561,7 +561,7 @@ void ConsoleReporter::printTestCaseAndSectionHeader() {
|
||||||
stream << lineOfChars('-') << '\n';
|
stream << lineOfChars('-') << '\n';
|
||||||
Colour colourGuard(Colour::FileName);
|
Colour colourGuard(Colour::FileName);
|
||||||
stream << lineInfo << '\n';
|
stream << lineInfo << '\n';
|
||||||
stream << lineOfChars('.') << '\n' << std::endl;
|
stream << lineOfChars('.') << "\n\n" << std::flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleReporter::printClosedHeader(std::string const& _name) {
|
void ConsoleReporter::printClosedHeader(std::string const& _name) {
|
||||||
|
|
Loading…
Reference in New Issue