mirror of
https://github.com/catchorg/Catch2.git
synced 2025-02-17 03:43:29 +01:00
Escape characters bug patch(v2.9.2)
This commit is contained in:
parent
3beccfb429
commit
2bcff9dd35
@ -28,7 +28,12 @@ namespace Catch {
|
|||||||
return m_testSpec;
|
return m_testSpec;
|
||||||
}
|
}
|
||||||
void TestSpecParser::visitChar( char c ) {
|
void TestSpecParser::visitChar( char c ) {
|
||||||
if( c == ',' ) {
|
if( (m_mode != EscapedName) && (c == '\\') ) {
|
||||||
|
escape();
|
||||||
|
m_substring += c;
|
||||||
|
m_patternName += c;
|
||||||
|
return;
|
||||||
|
}else if((m_mode != EscapedName) && (c == ',') ) {
|
||||||
endMode();
|
endMode();
|
||||||
addFilter();
|
addFilter();
|
||||||
return;
|
return;
|
||||||
@ -72,9 +77,6 @@ namespace Catch {
|
|||||||
case '"':
|
case '"':
|
||||||
startNewMode( QuotedName );
|
startNewMode( QuotedName );
|
||||||
return false;
|
return false;
|
||||||
case '\\':
|
|
||||||
escape();
|
|
||||||
return true;
|
|
||||||
default:
|
default:
|
||||||
startNewMode( Name );
|
startNewMode( Name );
|
||||||
return false;
|
return false;
|
||||||
@ -107,13 +109,15 @@ namespace Catch {
|
|||||||
case Tag:
|
case Tag:
|
||||||
return addPattern<TestSpec::TagPattern>();
|
return addPattern<TestSpec::TagPattern>();
|
||||||
case EscapedName:
|
case EscapedName:
|
||||||
return startNewMode( Name );
|
revertBackToLastMode();
|
||||||
|
return;
|
||||||
case None:
|
case None:
|
||||||
default:
|
default:
|
||||||
return startNewMode( None );
|
return startNewMode( None );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void TestSpecParser::escape() {
|
void TestSpecParser::escape() {
|
||||||
|
saveLastMode();
|
||||||
m_mode = EscapedName;
|
m_mode = EscapedName;
|
||||||
m_escapeChars.push_back( m_pos );
|
m_escapeChars.push_back( m_pos );
|
||||||
}
|
}
|
||||||
@ -141,6 +145,14 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestSpecParser::saveLastMode() {
|
||||||
|
lastMode = m_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestSpecParser::revertBackToLastMode() {
|
||||||
|
m_mode = lastMode;
|
||||||
|
}
|
||||||
|
|
||||||
TestSpec parseTestSpec( std::string const& arg ) {
|
TestSpec parseTestSpec( std::string const& arg ) {
|
||||||
return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec();
|
return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec();
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ namespace Catch {
|
|||||||
class TestSpecParser {
|
class TestSpecParser {
|
||||||
enum Mode{ None, Name, QuotedName, Tag, EscapedName };
|
enum Mode{ None, Name, QuotedName, Tag, EscapedName };
|
||||||
Mode m_mode = None;
|
Mode m_mode = None;
|
||||||
|
Mode lastMode = None;
|
||||||
bool m_exclusion = false;
|
bool m_exclusion = false;
|
||||||
std::size_t m_pos = 0;
|
std::size_t m_pos = 0;
|
||||||
std::string m_arg;
|
std::string m_arg;
|
||||||
@ -47,7 +48,9 @@ namespace Catch {
|
|||||||
void endMode();
|
void endMode();
|
||||||
void escape();
|
void escape();
|
||||||
bool isControlChar( char c ) const;
|
bool isControlChar( char c ) const;
|
||||||
|
void saveLastMode();
|
||||||
|
void revertBackToLastMode();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void addPattern() {
|
void addPattern() {
|
||||||
std::string token = m_patternName;
|
std::string token = m_patternName;
|
||||||
@ -80,4 +83,4 @@ namespace Catch {
|
|||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
|
Loading…
Reference in New Issue
Block a user