From e5632e5e941dd5185bcbbaec42b2357fca8921af Mon Sep 17 00:00:00 2001 From: Kari Argillander Date: Thu, 22 Jun 2023 11:22:50 +0300 Subject: [PATCH] Add -Wdouble-promotion to common warnings This has not huge benefits in Catch2 codebase, but it is still easy to take in use and it will benefit those which build catch2 with project default compiler options. Signed-off-by: Kari Argillander --- CMake/CatchMiscFunctions.cmake | 1 + src/catch2/catch_approx.cpp | 2 +- tests/SelfTest/UsageTests/Condition.tests.cpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMake/CatchMiscFunctions.cmake b/CMake/CatchMiscFunctions.cmake index 44c875007f..502994e3a7 100644 --- a/CMake/CatchMiscFunctions.cmake +++ b/CMake/CatchMiscFunctions.cmake @@ -53,6 +53,7 @@ function(add_warnings_to_targets targets) "-Wdangling" "-Wdeprecated" "-Wdeprecated-register" + "-Wdouble-promotion" "-Wexceptions" "-Wexit-time-destructors" "-Wextra" diff --git a/src/catch2/catch_approx.cpp b/src/catch2/catch_approx.cpp index 407586d1d5..7da8364554 100644 --- a/src/catch2/catch_approx.cpp +++ b/src/catch2/catch_approx.cpp @@ -25,7 +25,7 @@ bool marginComparison(double lhs, double rhs, double margin) { namespace Catch { Approx::Approx ( double value ) - : m_epsilon( std::numeric_limits::epsilon()*100. ), + : m_epsilon( std::numeric_limits::epsilon()*100.f ), m_margin( 0.0 ), m_scale( 0.0 ), m_value( value ) diff --git a/tests/SelfTest/UsageTests/Condition.tests.cpp b/tests/SelfTest/UsageTests/Condition.tests.cpp index 211dd3b915..21c04a1a4f 100644 --- a/tests/SelfTest/UsageTests/Condition.tests.cpp +++ b/tests/SelfTest/UsageTests/Condition.tests.cpp @@ -136,7 +136,7 @@ TEST_CASE( "Ordering comparison checks that should succeed" ) REQUIRE( data.float_nine_point_one > 9 ); REQUIRE( data.float_nine_point_one < 10 ); - REQUIRE( data.float_nine_point_one < 9.2 ); + REQUIRE( data.float_nine_point_one < 9.2f ); REQUIRE( data.str_hello <= "hello" ); REQUIRE( data.str_hello >= "hello" ); @@ -163,7 +163,7 @@ TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" ) CHECK( data.float_nine_point_one < 9 ); CHECK( data.float_nine_point_one > 10 ); - CHECK( data.float_nine_point_one > 9.2 ); + CHECK( data.float_nine_point_one > 9.2f ); CHECK( data.str_hello > "hello" ); CHECK( data.str_hello < "hello" );