Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Small test spec parser refactoring

Commit
72e67693d4dbaca09e7da017da328209daea8a51
Author
Phil Nash ·
Parents
f8cff10ff6cd

Files · Download .tar.gz

Changes

 projects/SelfTest/CmdLineTests.cpp | 13 ++++++++-----
 1 file 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() {