summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/catch/include/internal/catch_test_spec_parser.hpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/catch/include/internal/catch_test_spec_parser.hpp')
-rw-r--r--3rdparty/catch/include/internal/catch_test_spec_parser.hpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/3rdparty/catch/include/internal/catch_test_spec_parser.hpp b/3rdparty/catch/include/internal/catch_test_spec_parser.hpp
index 3f794c6b97d..0c328365af4 100644
--- a/3rdparty/catch/include/internal/catch_test_spec_parser.hpp
+++ b/3rdparty/catch/include/internal/catch_test_spec_parser.hpp
@@ -19,11 +19,12 @@
namespace Catch {
class TestSpecParser {
- enum Mode{ None, Name, QuotedName, Tag };
+ enum Mode{ None, Name, QuotedName, Tag, EscapedName };
Mode m_mode;
bool m_exclusion;
std::size_t m_start, m_pos;
std::string m_arg;
+ std::vector<std::size_t> m_escapeChars;
TestSpec::Filter m_currentFilter;
TestSpec m_testSpec;
ITagAliasRegistry const* m_tagAliases;
@@ -36,6 +37,7 @@ namespace Catch {
m_exclusion = false;
m_start = std::string::npos;
m_arg = m_tagAliases->expandAliases( arg );
+ m_escapeChars.clear();
for( m_pos = 0; m_pos < m_arg.size(); ++m_pos )
visitChar( m_arg[m_pos] );
if( m_mode == Name )
@@ -54,6 +56,7 @@ namespace Catch {
case '~': m_exclusion = true; return;
case '[': return startNewMode( Tag, ++m_pos );
case '"': return startNewMode( QuotedName, ++m_pos );
+ case '\\': return escape();
default: startNewMode( Name, m_pos ); break;
}
}
@@ -69,7 +72,11 @@ namespace Catch {
addPattern<TestSpec::NamePattern>();
startNewMode( Tag, ++m_pos );
}
+ else if( c == '\\' )
+ escape();
}
+ else if( m_mode == EscapedName )
+ m_mode = Name;
else if( m_mode == QuotedName && c == '"' )
addPattern<TestSpec::NamePattern>();
else if( m_mode == Tag && c == ']' )
@@ -79,10 +86,19 @@ namespace Catch {
m_mode = mode;
m_start = start;
}
+ void escape() {
+ if( m_mode == None )
+ m_start = m_pos;
+ m_mode = EscapedName;
+ m_escapeChars.push_back( m_pos );
+ }
std::string subString() const { return m_arg.substr( m_start, m_pos - m_start ); }
template<typename T>
void addPattern() {
std::string token = subString();
+ for( size_t i = 0; i < m_escapeChars.size(); ++i )
+ token = token.substr( 0, m_escapeChars[i]-i ) + token.substr( m_escapeChars[i]+1-i );
+ m_escapeChars.clear();
if( startsWith( token, "exclude:" ) ) {
m_exclusion = true;
token = token.substr( 8 );