diff options
| author | Martin Hořeňovský | 2021-09-09 11:04:34 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-09-09 11:04:34 +0200 |
| commit | 12bca890b7a0f50357f47ca0517578a7c5ca2e15 (patch) | |
| tree | e53a63d16334c228e6e4d0eef0f84ec1f761e095 /src/catch2/internal | |
| parent | 317db823967ef36a3ed1fa6d63fc7d99dd5e8380 (diff) | |
| download | catch3-12bca890b7a0f50357f47ca0517578a7c5ca2e15.tar.gz | |
Use StringRefs in SectionTracker's filter bookkeeping
Diffstat (limited to 'src/catch2/internal')
| -rw-r--r-- | src/catch2/internal/catch_test_case_tracker.cpp | 12 | ||||
| -rw-r--r-- | src/catch2/internal/catch_test_case_tracker.hpp | 9 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/catch2/internal/catch_test_case_tracker.cpp b/src/catch2/internal/catch_test_case_tracker.cpp index a0e883b5..ce76dcba 100644 --- a/src/catch2/internal/catch_test_case_tracker.cpp +++ b/src/catch2/internal/catch_test_case_tracker.cpp @@ -186,7 +186,7 @@ namespace TestCaseTracking { bool complete = true; if (m_filters.empty() - || m_filters[0] == "" + || m_filters[0].empty() || std::find(m_filters.begin(), m_filters.end(), m_trimmed_name) != m_filters.end()) { complete = TrackerBase::isComplete(); } @@ -223,21 +223,21 @@ namespace TestCaseTracking { void SectionTracker::addInitialFilters( std::vector<std::string> const& filters ) { if( !filters.empty() ) { m_filters.reserve( m_filters.size() + filters.size() + 2 ); - m_filters.emplace_back(""); // Root - should never be consulted - m_filters.emplace_back(""); // Test Case - not a section filter + m_filters.emplace_back(StringRef{}); // Root - should never be consulted + m_filters.emplace_back(StringRef{}); // Test Case - not a section filter m_filters.insert( m_filters.end(), filters.begin(), filters.end() ); } } - void SectionTracker::addNextFilters( std::vector<std::string> const& filters ) { + void SectionTracker::addNextFilters( std::vector<StringRef> const& filters ) { if( filters.size() > 1 ) m_filters.insert( m_filters.end(), filters.begin()+1, filters.end() ); } - std::vector<std::string> const& SectionTracker::getFilters() const { + std::vector<StringRef> const& SectionTracker::getFilters() const { return m_filters; } - std::string const& SectionTracker::trimmedName() const { + StringRef SectionTracker::trimmedName() const { return m_trimmed_name; } diff --git a/src/catch2/internal/catch_test_case_tracker.hpp b/src/catch2/internal/catch_test_case_tracker.hpp index 1242d8de..0355f195 100644 --- a/src/catch2/internal/catch_test_case_tracker.hpp +++ b/src/catch2/internal/catch_test_case_tracker.hpp @@ -10,6 +10,7 @@ #include <catch2/internal/catch_source_line_info.hpp> #include <catch2/internal/catch_unique_ptr.hpp> +#include <catch2/internal/catch_stringref.hpp> #include <string> #include <vector> @@ -164,7 +165,7 @@ namespace TestCaseTracking { }; class SectionTracker : public TrackerBase { - std::vector<std::string> m_filters; + std::vector<StringRef> m_filters; std::string m_trimmed_name; public: SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); @@ -178,11 +179,11 @@ namespace TestCaseTracking { void tryOpen(); void addInitialFilters( std::vector<std::string> const& filters ); - void addNextFilters( std::vector<std::string> const& filters ); + void addNextFilters( std::vector<StringRef> const& filters ); //! Returns filters active in this tracker - std::vector<std::string> const& getFilters() const; + std::vector<StringRef> const& getFilters() const; //! Returns whitespace-trimmed name of the tracked section - std::string const& trimmedName() const; + StringRef trimmedName() const; }; } // namespace TestCaseTracking |