Warning fixes in examples and tests

This commit is contained in:
Martin Hořeňovský 2019-10-31 14:29:59 +01:00
parent 3136c4fb6a
commit 776a4686c7
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
3 changed files with 16 additions and 7 deletions

View File

@ -10,11 +10,12 @@
#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
class out_buff : public std::stringbuf { class out_buff : public std::stringbuf {
std::FILE* m_stream; std::FILE* m_stream;
public: public:
out_buff(std::FILE* stream) :m_stream(stream) {} out_buff(std::FILE* stream):m_stream(stream) {}
~out_buff() { pubsync(); } ~out_buff();
int sync() { int sync() {
int ret = 0; int ret = 0;
for (unsigned char c : str()) { 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 { namespace Catch {
std::ostream& cout() { std::ostream& cout() {
static std::ostream ret(new out_buff(stdout)); static std::ostream ret(new out_buff(stdout));

View File

@ -22,15 +22,17 @@ public:
} }
} }
std::string const& get() const override { std::string const& get() const override;
return m_line;
}
bool next() override { bool next() override {
return !!std::getline(m_stream, m_line); 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 // This helper function provides a nicer UX when instantiating the generator
// Notice that it returns an instance of GeneratorWrapper<std::string>, which // Notice that it returns an instance of GeneratorWrapper<std::string>, which
// is a value-wrapper around std::unique_ptr<IGenerator<std::string>>. // is a value-wrapper around std::unique_ptr<IGenerator<std::string>>.

View File

@ -9,12 +9,12 @@
// We need 2 types with non-trivial copies/moves // We need 2 types with non-trivial copies/moves
struct MyType1 { struct MyType1 {
MyType1() = default; MyType1() = default;
MyType1(MyType1 const&) { throw 1; } [[noreturn]] MyType1(MyType1 const&) { throw 1; }
MyType1& operator=(MyType1 const&) { throw 3; } MyType1& operator=(MyType1 const&) { throw 3; }
}; };
struct MyType2 { struct MyType2 {
MyType2() = default; MyType2() = default;
MyType2(MyType2 const&) { throw 2; } [[noreturn]] MyType2(MyType2 const&) { throw 2; }
MyType2& operator=(MyType2 const&) { throw 4; } MyType2& operator=(MyType2 const&) { throw 4; }
}; };