mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
Use StringRefs in SectionTracker's filter bookkeeping
This commit is contained in:
parent
317db82396
commit
12bca890b7
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user