From 0ab2c2906b95f41dfa7b692ca4ab856e20ebd3d4 Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Mon, 6 Apr 2020 13:52:09 +0100 Subject: [PATCH] Fix type conversion warnings. (#951) * Fix type conversion warnings. Fixes #949 Tested locally (Linux/clang), but warnings are on MSVC so may differ. * Drop the ULP so the double test passes --- src/benchmark_runner.cc | 5 +++-- test/statistics_gtest.cc | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/benchmark_runner.cc b/src/benchmark_runner.cc index c414eff9..7bc6b632 100644 --- a/src/benchmark_runner.cc +++ b/src/benchmark_runner.cc @@ -263,8 +263,9 @@ class BenchmarkRunner { if (multiplier <= 1.0) multiplier = 2.0; // So what seems to be the sufficiently-large iteration count? Round up. - const IterationCount max_next_iters = - std::lround(std::max(multiplier * i.iters, i.iters + 1.0)); + const IterationCount max_next_iters = static_cast( + std::lround(std::max(multiplier * static_cast(i.iters), + static_cast(i.iters) + 1.0))); // But we do have *some* sanity limits though.. const IterationCount next_iters = std::min(max_next_iters, kMaxIterations); diff --git a/test/statistics_gtest.cc b/test/statistics_gtest.cc index 99e31492..3ddc72dd 100644 --- a/test/statistics_gtest.cc +++ b/test/statistics_gtest.cc @@ -21,8 +21,8 @@ TEST(StatisticsTest, Median) { TEST(StatisticsTest, StdDev) { EXPECT_DOUBLE_EQ(benchmark::StatisticsStdDev({101, 101, 101, 101}), 0.0); EXPECT_DOUBLE_EQ(benchmark::StatisticsStdDev({1, 2, 3}), 1.0); - EXPECT_FLOAT_EQ(benchmark::StatisticsStdDev({1.5, 2.4, 3.3, 4.2, 5.1}), - 1.42302495); + EXPECT_DOUBLE_EQ(benchmark::StatisticsStdDev({2.5, 2.4, 3.3, 4.2, 5.1}), + 1.151086443322134); } } // end namespace