From 293012a002ef5351adbfcc0cbf7cdfdc93aed115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 8 Sep 2019 18:20:49 +0200 Subject: [PATCH] Inline SourceLineInfo::empty definition --- docs/deprecations.md | 5 +++++ include/internal/catch_common.cpp | 3 --- include/internal/catch_common.h | 2 +- include/reporters/catch_reporter_console.cpp | 9 ++++----- include/reporters/catch_reporter_teamcity.hpp | 3 +-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/deprecations.md b/docs/deprecations.md index 0489e1ff..77830298 100644 --- a/docs/deprecations.md +++ b/docs/deprecations.md @@ -39,6 +39,11 @@ apart from writing it out for `--list-tests -v high`. Because it isn't actually used nor documented, and brings complications to Catch2's internals, description support will be removed. +### SourceLineInfo::empty() + +There should be no reason to ever have an empty `SourceLineInfo`, so the +method will be removed. + ## Planned changes diff --git a/include/internal/catch_common.cpp b/include/internal/catch_common.cpp index b2fca4c4..790acbe5 100644 --- a/include/internal/catch_common.cpp +++ b/include/internal/catch_common.cpp @@ -15,9 +15,6 @@ namespace Catch { - bool SourceLineInfo::empty() const noexcept { - return file[0] == '\0'; - } bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept { return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0); } diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h index e4745622..5e097fbf 100644 --- a/include/internal/catch_common.h +++ b/include/internal/catch_common.h @@ -57,7 +57,7 @@ namespace Catch { SourceLineInfo( SourceLineInfo&& ) noexcept = default; SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; - bool empty() const noexcept; + bool empty() const noexcept { return file[0] == '\0'; } bool operator == ( SourceLineInfo const& other ) const noexcept; bool operator < ( SourceLineInfo const& other ) const noexcept; diff --git a/include/reporters/catch_reporter_console.cpp b/include/reporters/catch_reporter_console.cpp index e38e34cf..55b0c9ed 100644 --- a/include/reporters/catch_reporter_console.cpp +++ b/include/reporters/catch_reporter_console.cpp @@ -530,11 +530,10 @@ void ConsoleReporter::printTestCaseAndSectionHeader() { SourceLineInfo lineInfo = m_sectionStack.back().lineInfo; - if (!lineInfo.empty()) { - stream << getLineOfChars<'-'>() << '\n'; - Colour colourGuard(Colour::FileName); - stream << lineInfo << '\n'; - } + + stream << getLineOfChars<'-'>() << '\n'; + Colour colourGuard(Colour::FileName); + stream << lineInfo << '\n'; stream << getLineOfChars<'.'>() << '\n' << std::endl; } diff --git a/include/reporters/catch_reporter_teamcity.hpp b/include/reporters/catch_reporter_teamcity.hpp index eca2885c..47b7e4aa 100644 --- a/include/reporters/catch_reporter_teamcity.hpp +++ b/include/reporters/catch_reporter_teamcity.hpp @@ -183,8 +183,7 @@ namespace Catch { SourceLineInfo lineInfo = m_sectionStack.front().lineInfo; - if( !lineInfo.empty() ) - os << lineInfo << "\n"; + os << lineInfo << "\n"; os << getLineOfChars<'.'>() << "\n\n"; }