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

Warning fixes in examples and tests

Commit
776a4686c7fa783fe3c57b7dbcefba57fe142c55
Author
Martin Hořeňovský ·
Parents
3136c4fb6aeb

Files · Download .tar.gz

Changes

 examples/231-Cfg-OutputStreams.cpp                     | 11 +++++++++--
 examples/301-Gen-MapTypeConversion.cpp                 |  8 +++++---
 projects/SelfTest/UsageTests/ToStringVariant.tests.cpp |  4 ++--
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/examples/231-Cfg-OutputStreams.cpp b/examples/231-Cfg-OutputStreams.cpp
index efa99971..2f42c297 100644
--- a/examples/231-Cfg-OutputStreams.cpp
+++ b/examples/231-Cfg-OutputStreams.cpp
@@ -10,11 +10,12 @@
 #define CATCH_CONFIG_MAIN
 #include <catch2/catch.hpp>
 
+
 class out_buff : public std::stringbuf {
     std::FILE* m_stream;
 public:
-    out_buff(std::FILE* stream) :m_stream(stream) {}
-    ~out_buff() { pubsync(); }
+    out_buff(std::FILE* stream):m_stream(stream) {}
+    ~out_buff();
     int sync() {
         int ret = 0;
         for (unsigned char c : str()) {
@@ -29,6 +30,12 @@ public:
     }
 };
 
+out_buff::~out_buff() { pubsync(); }
+
+#if defined(__clang__)
+#pragma clang diagnostic ignored "-Wexit-time-destructors" // static variables in cout/cerr/clog
+#endif
+
 namespace Catch {
     std::ostream& cout() {
         static std::ostream ret(new out_buff(stdout));
diff --git a/examples/301-Gen-MapTypeConversion.cpp b/examples/301-Gen-MapTypeConversion.cpp
index b6377e99..9bc7adf4 100644
--- a/examples/301-Gen-MapTypeConversion.cpp
+++ b/examples/301-Gen-MapTypeConversion.cpp
@@ -22,15 +22,17 @@ public:
         }
     }
 
-    std::string const& get() const override {
-        return m_line;
-    }
+    std::string const& get() const override;
     
     bool next() override {
         return !!std::getline(m_stream, m_line);
     }
 };
 
+std::string const& get() const {
+    return m_line;
+}
+
 // This helper function provides a nicer UX when instantiating the generator
 // Notice that it returns an instance of GeneratorWrapper<std::string>, which
 // is a value-wrapper around std::unique_ptr<IGenerator<std::string>>.
diff --git a/projects/SelfTest/UsageTests/ToStringVariant.tests.cpp b/projects/SelfTest/UsageTests/ToStringVariant.tests.cpp
index 60b3f903..c6809c0f 100644
--- a/projects/SelfTest/UsageTests/ToStringVariant.tests.cpp
+++ b/projects/SelfTest/UsageTests/ToStringVariant.tests.cpp
@@ -9,12 +9,12 @@
 // We need 2 types with non-trivial copies/moves
 struct MyType1 {
     MyType1() = default;
-    MyType1(MyType1 const&) { throw 1; }
+    [[noreturn]] MyType1(MyType1 const&) { throw 1; }
     MyType1& operator=(MyType1 const&) { throw 3; }
 };
 struct MyType2 {
     MyType2() = default;
-    MyType2(MyType2 const&) { throw 2; }
+    [[noreturn]] MyType2(MyType2 const&) { throw 2; }
     MyType2& operator=(MyType2 const&) { throw 4; }
 };