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

Escape characters bug patch(v2.9.2)

Commit
2bcff9dd3581708d50734d3f55949146e5ba0162
Author
amitherman95 ·
Committer
Martin Hořeňovský
Parents
3beccfb42986

Files · Download .tar.gz

Changes

 include/internal/catch_test_spec_parser.cpp | 22 +++++++++++++++++-----
 include/internal/catch_test_spec_parser.h   |  7 +++++--
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/include/internal/catch_test_spec_parser.cpp b/include/internal/catch_test_spec_parser.cpp
index a910ac7e..5cbbdeb7 100644
--- a/include/internal/catch_test_spec_parser.cpp
+++ b/include/internal/catch_test_spec_parser.cpp
@@ -28,7 +28,12 @@ namespace Catch {
         return m_testSpec;
     }
     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();
             addFilter();
             return;
@@ -72,9 +77,6 @@ namespace Catch {
         case '"':
             startNewMode( QuotedName );
             return false;
-        case '\\':
-            escape();
-            return true;
         default:
             startNewMode( Name );
             return false;
@@ -107,13 +109,15 @@ namespace Catch {
         case Tag:
             return addPattern<TestSpec::TagPattern>();
         case EscapedName:
-            return startNewMode( Name );
+            revertBackToLastMode();
+            return;
         case None:
         default:
             return startNewMode( None );
         }
     }
     void TestSpecParser::escape() {
+        saveLastMode();
         m_mode = EscapedName;
         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 ) {
         return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec();
     }
diff --git a/include/internal/catch_test_spec_parser.h b/include/internal/catch_test_spec_parser.h
index 5b02bf6d..778da134 100644
--- a/include/internal/catch_test_spec_parser.h
+++ b/include/internal/catch_test_spec_parser.h
@@ -22,6 +22,7 @@ namespace Catch {
     class TestSpecParser {
         enum Mode{ None, Name, QuotedName, Tag, EscapedName };
         Mode m_mode = None;
+        Mode lastMode = None;
         bool m_exclusion = false;
         std::size_t m_pos = 0;
         std::string m_arg;
@@ -47,7 +48,9 @@ namespace Catch {
         void endMode();
         void escape();
         bool isControlChar( char c ) const;
-
+        void saveLastMode();
+        void revertBackToLastMode();
+        
         template<typename T>
         void addPattern() {
             std::string token = m_patternName;
@@ -80,4 +83,4 @@ namespace Catch {
 #pragma clang diagnostic pop
 #endif
 
-#endif // TWOBLUECUBES_CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
+#endif // TWOBLUECUBES_CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
\ No newline at end of file