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 <kari.argillander@gmail.com>
This commit is contained in:
Kari Argillander 2023-06-22 11:22:50 +03:00
parent e4b16053a6
commit e5632e5e94
3 changed files with 4 additions and 3 deletions

View File

@ -53,6 +53,7 @@ function(add_warnings_to_targets targets)
"-Wdangling" "-Wdangling"
"-Wdeprecated" "-Wdeprecated"
"-Wdeprecated-register" "-Wdeprecated-register"
"-Wdouble-promotion"
"-Wexceptions" "-Wexceptions"
"-Wexit-time-destructors" "-Wexit-time-destructors"
"-Wextra" "-Wextra"

View File

@ -25,7 +25,7 @@ bool marginComparison(double lhs, double rhs, double margin) {
namespace Catch { namespace Catch {
Approx::Approx ( double value ) Approx::Approx ( double value )
: m_epsilon( std::numeric_limits<float>::epsilon()*100. ), : m_epsilon( std::numeric_limits<float>::epsilon()*100.f ),
m_margin( 0.0 ), m_margin( 0.0 ),
m_scale( 0.0 ), m_scale( 0.0 ),
m_value( value ) m_value( value )

View File

@ -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 > 9 );
REQUIRE( data.float_nine_point_one < 10 ); 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" );
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 < 9 );
CHECK( data.float_nine_point_one > 10 ); 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" );
CHECK( data.str_hello < "hello" ); CHECK( data.str_hello < "hello" );