mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-30 01:03:30 +01:00
Small test spec parser refactoring
This commit is contained in:
parent
f8cff10ff6
commit
72e67693d4
@ -124,9 +124,9 @@ namespace Catch {
|
|||||||
switch( c ) {
|
switch( c ) {
|
||||||
case ' ': return;
|
case ' ': return;
|
||||||
case '~': m_exclusion = true; return;
|
case '~': m_exclusion = true; return;
|
||||||
case '[': m_mode = Tag; m_start = ++m_pos; return;
|
case '[': return startNewMode( Tag, ++m_pos );
|
||||||
case '"': m_mode = QuotedName; m_start = m_pos+1; return;
|
case '"': return startNewMode( QuotedName, ++m_pos );
|
||||||
default: m_mode = Name; m_start = m_pos; break;
|
default: startNewMode( Name, m_pos ); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( m_mode == Name ) {
|
if( m_mode == Name ) {
|
||||||
@ -139,8 +139,7 @@ namespace Catch {
|
|||||||
m_exclusion = true;
|
m_exclusion = true;
|
||||||
else
|
else
|
||||||
addPattern<TestSpec::NamePattern>();
|
addPattern<TestSpec::NamePattern>();
|
||||||
m_mode = Tag;
|
startNewMode( Tag, ++m_pos );
|
||||||
m_start = m_pos+1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( m_mode == QuotedName && c == '"' )
|
else if( m_mode == QuotedName && c == '"' )
|
||||||
@ -148,6 +147,10 @@ namespace Catch {
|
|||||||
else if( m_mode == Tag && c == ']' )
|
else if( m_mode == Tag && c == ']' )
|
||||||
addPattern<TestSpec::TagPattern>();
|
addPattern<TestSpec::TagPattern>();
|
||||||
}
|
}
|
||||||
|
void startNewMode( Mode mode, std::size_t start ) {
|
||||||
|
m_mode = mode;
|
||||||
|
m_start = start;
|
||||||
|
}
|
||||||
std::string subString() const { return m_arg.substr( m_start, m_pos - m_start ); }
|
std::string subString() const { return m_arg.substr( m_start, m_pos - m_start ); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void addPattern() {
|
void addPattern() {
|
||||||
|
Loading…
Reference in New Issue
Block a user