From 0033f6db33b2ef5976d3b58d8da37d8c801eafd1 Mon Sep 17 00:00:00 2001 From: Leodasce Sewanou Date: Fri, 12 Dec 2025 10:54:41 +0100 Subject: [PATCH] updates [Clang-tidy] fix warning for Tscal used as loop counter Replace for loop by a while loop. updates --- src/tests/shammath/sphkernelsTests.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tests/shammath/sphkernelsTests.cpp b/src/tests/shammath/sphkernelsTests.cpp index d2785be002..73419fb1e6 100644 --- a/src/tests/shammath/sphkernelsTests.cpp +++ b/src/tests/shammath/sphkernelsTests.cpp @@ -19,6 +19,7 @@ #include "shamtest/PyScriptHandle.hpp" #include "shamtest/details/TestResult.hpp" #include "shamtest/shamtest.hpp" +#include #include template @@ -82,13 +83,17 @@ inline void validate_kernel_3d( // is df = f' ? Tscal L2_sum = 0; Tscal step = 0.01; - for (Tscal x = 0; x < Ker::Rkern; x += step) { - Tscal diff = Ker::df(x) - shammath::derivative_upwind(x, dx, [](Tscal x) { + + const int num_steps = static_cast(std::ceil(Ker::Rkern / step)); + for (int i = 0; i < num_steps; i++) { + const Tscal x = i * step; + Tscal diff = Ker::df(x) - shammath::derivative_upwind(x, dx, [](Tscal x) { return Ker::f(x); }); diff *= gen_norm3d; L2_sum += diff * diff * step; } + REQUIRE_FLOAT_EQUAL(L2_sum, 0, tol); }