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

Catch::LeakDetector: added cleanup call to destructor

simple code with provided main function which just returns 0
leaks memory due to fact that singletons are not cleaned up

running valgrind on such simple application reports that 752 bytes
are still available in 11 blocks

this commit adds destructor to Catch::LeakDetector which calls
Catch::cleanUp()
Commit
ab98afe68b111118907ff89131f0c2cc8e0aef9a
Author
Jozef Grajciar ·
Committer
Martin Hořeňovský
Parents
054d356332a0

Files · Download .tar.gz

Changes

 include/internal/catch_leak_detector.cpp | 5 +++++
 include/internal/catch_leak_detector.h   | 1 +
 2 files changed, 6 insertions(+)

diff --git a/include/internal/catch_leak_detector.cpp b/include/internal/catch_leak_detector.cpp
index dd160d9c..7a30e8a1 100644
--- a/include/internal/catch_leak_detector.cpp
+++ b/include/internal/catch_leak_detector.cpp
@@ -6,6 +6,7 @@
  */
 
  #include "catch_leak_detector.h"
+ #include "catch_interfaces_registry_hub.h"
 
 
 #ifdef CATCH_CONFIG_WINDOWS_CRTDBG
@@ -30,3 +31,7 @@ namespace Catch {
     Catch::LeakDetector::LeakDetector() {}
 
 #endif
+
+Catch::LeakDetector::~LeakDetector() {
+    Catch::cleanUp();
+}
diff --git a/include/internal/catch_leak_detector.h b/include/internal/catch_leak_detector.h
index bfb0b429..633457ac 100644
--- a/include/internal/catch_leak_detector.h
+++ b/include/internal/catch_leak_detector.h
@@ -11,6 +11,7 @@ namespace Catch {
 
     struct LeakDetector {
         LeakDetector();
+        ~LeakDetector();
     };
 
 }