mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-02 05:15:39 +02:00
Add Wfloat-equal to default-enabled warnings
This is kinda messy, because there is no good way to signal to the compiler that some code uses direct comparison of floating point numbers intentionally, so instead we have to use diagnostic pragmas. We also have to over-suppress the test files, because Clang (and possibly GCC) still issue warnings from template instantiation even if the instantion site is under warning suppression, so the template definition has to be under warning suppression as well. Closes #2406
This commit is contained in:
@@ -6,6 +6,10 @@
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
#if defined( __GNUC__ ) || defined( __clang__ )
|
||||
# pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#endif
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/catch_template_test_macros.hpp>
|
||||
#include <array>
|
||||
|
@@ -845,10 +845,10 @@ TEST_CASE( "Combining concrete matchers does not use templated matchers",
|
||||
|
||||
struct MatcherA : Catch::Matchers::MatcherGenericBase {
|
||||
std::string describe() const override {
|
||||
return "equals: (int) 1 or (float) 1.0f";
|
||||
return "equals: (int) 1 or (string) \"1\"";
|
||||
}
|
||||
bool match( int i ) const { return i == 1; }
|
||||
bool match( float f ) const { return f == 1.0f; }
|
||||
bool match( std::string s ) const { return s == "1"; }
|
||||
};
|
||||
|
||||
struct MatcherB : Catch::Matchers::MatcherGenericBase {
|
||||
|
Reference in New Issue
Block a user