diff options
| author | Phil Nash | 2014-05-16 07:07:28 +0100 |
|---|---|---|
| committer | Phil Nash | 2014-05-16 07:07:28 +0100 |
| commit | 72e67693d4dbaca09e7da017da328209daea8a51 (patch) | |
| tree | bfce88642776402fc8ef26290ec867127bdb190a | |
| parent | f8cff10ff6cd70bc7fffb469643fe5ee999f3c69 (diff) | |
| download | catch3-72e67693d4dbaca09e7da017da328209daea8a51.tar.gz | |
Small test spec parser refactoring
| -rw-r--r-- | projects/SelfTest/CmdLineTests.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/projects/SelfTest/CmdLineTests.cpp b/projects/SelfTest/CmdLineTests.cpp index 27bf2a2f..b4649bcc 100644 --- a/projects/SelfTest/CmdLineTests.cpp +++ b/projects/SelfTest/CmdLineTests.cpp @@ -124,9 +124,9 @@ namespace Catch { switch( c ) { case ' ': return; case '~': m_exclusion = true; return; - case '[': m_mode = Tag; m_start = ++m_pos; return; - case '"': m_mode = QuotedName; m_start = m_pos+1; return; - default: m_mode = Name; m_start = m_pos; break; + case '[': return startNewMode( Tag, ++m_pos ); + case '"': return startNewMode( QuotedName, ++m_pos ); + default: startNewMode( Name, m_pos ); break; } } if( m_mode == Name ) { @@ -139,8 +139,7 @@ namespace Catch { m_exclusion = true; else addPattern<TestSpec::NamePattern>(); - m_mode = Tag; - m_start = m_pos+1; + startNewMode( Tag, ++m_pos ); } } else if( m_mode == QuotedName && c == '"' ) @@ -148,6 +147,10 @@ namespace Catch { else if( m_mode == Tag && c == ']' ) 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 ); } template<typename T> void addPattern() { |