Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/projects
diff options
context:
space:
mode:
authorPhil Nash2014-05-16 07:07:28 +0100
committerPhil Nash2014-05-16 07:07:28 +0100
commit72e67693d4dbaca09e7da017da328209daea8a51 (patch)
treebfce88642776402fc8ef26290ec867127bdb190a /projects
parentf8cff10ff6cd70bc7fffb469643fe5ee999f3c69 (diff)
downloadcatch3-72e67693d4dbaca09e7da017da328209daea8a51.tar.gz
Small test spec parser refactoring
Diffstat (limited to 'projects')
-rw-r--r--projects/SelfTest/CmdLineTests.cpp13
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() {