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

Fixed leak

Commit
92f2d32f74c1d16c9742581f03b2b2a02b67dabb
Author
Phil Nash ·
Parents
5cf94a80434e

Files · Download .tar.gz

Changes

 Test/TrickyTests.cpp            |  8 ++++++++
 internal/catch_capture.hpp      |  3 +--
 internal/catch_testcaseinfo.hpp | 12 +++++++++---
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/Test/TrickyTests.cpp b/Test/TrickyTests.cpp
index 08074dd7..b3cfc6f0 100644
--- a/Test/TrickyTests.cpp
+++ b/Test/TrickyTests.cpp
@@ -40,4 +40,12 @@ TEST_CASE( "succeeding/Tricky/complex lhs", "Where the LHS is not a simple value
 
     // This only captures part of the expression, but issues a warning about the rest
     EXPECT( a == 2 || b == 2 );
+}
+
+TEST_CASE( "succeeding/Tricky/complex lhs/2", "Where the LHS is not a simple value" )
+{
+    int a = 1;
+    
+    // This only captures part of the expression, but issues a warning about the rest
+//    EXPECT( a + 1 == 2);
 }
\ No newline at end of file
diff --git a/internal/catch_capture.hpp b/internal/catch_capture.hpp
index e7533cac..6e95e3f4 100644
--- a/internal/catch_capture.hpp
+++ b/internal/catch_capture.hpp
@@ -66,8 +66,7 @@ public:
         m_expressionIncomplete = true;
         return *this;
     }
-    
-    
+        
 private:
     friend class ResultBuilder;
     void setLhs( const std::string& lhs )
diff --git a/internal/catch_testcaseinfo.hpp b/internal/catch_testcaseinfo.hpp
index 7a8185ca..62bbeb87 100644
--- a/internal/catch_testcaseinfo.hpp
+++ b/internal/catch_testcaseinfo.hpp
@@ -48,9 +48,8 @@ namespace Catch
         
         TestCaseInfo& operator = ( const TestCaseInfo& other )
         {
-            test = other.test->clone();
-            name = other.name;
-            description = description;
+            TestCaseInfo temp( other );
+            swap( temp );
             return *this;
         }
         
@@ -73,6 +72,13 @@ namespace Catch
             return description;
         }
         
+        void swap( TestCaseInfo& other )
+        {
+            std::swap( test, other.test );
+            name.swap( other.name );
+            description.swap( other.description );
+        }
+        
     private:
         TestCase* test;
         std::string name;