From 8aed60912c6acb55018f8345a136409c63c63de2 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Wed, 3 Sep 2025 00:13:58 -0400 Subject: [PATCH] lint --- tests/basictest.cpp | 66 ++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/tests/basictest.cpp b/tests/basictest.cpp index f509e43..58f0b42 100644 --- a/tests/basictest.cpp +++ b/tests/basictest.cpp @@ -2106,15 +2106,21 @@ void integer_multiplication_by_power_of_10_test(Int mantissa, } template -void verify_integer_multiplication_by_power_of_10(Int mantissa, int32_t decimal_exponent) { - std::string constructed_string = std::to_string(mantissa) + "e" + std::to_string(decimal_exponent); - double expected_result; - auto result = fast_float::from_chars(constructed_string.data(), constructed_string.data() + constructed_string.size(), expected_result); - if(result.ec != std::errc()) { - INFO("Failed to parse: " << constructed_string); - } - std::cout << "Testing: " << constructed_string << " -> " << fHexAndDec(expected_result) << "\n"; - integer_multiplication_by_power_of_10_test(mantissa, decimal_exponent, expected_result); +void verify_integer_multiplication_by_power_of_10(Int mantissa, + int32_t decimal_exponent) { + std::string constructed_string = + std::to_string(mantissa) + "e" + std::to_string(decimal_exponent); + double expected_result; + auto result = fast_float::from_chars( + constructed_string.data(), + constructed_string.data() + constructed_string.size(), expected_result); + if (result.ec != std::errc()) { + INFO("Failed to parse: " << constructed_string); + } + std::cout << "Testing: " << constructed_string << " -> " + << fHexAndDec(expected_result) << "\n"; + integer_multiplication_by_power_of_10_test(mantissa, decimal_exponent, + expected_result); } TEST_CASE("multiply_integer_and_power_of_10") { @@ -2158,18 +2164,20 @@ TEST_CASE("multiply_integer_and_power_of_10") { verify_integer_multiplication_by_power_of_10(1, -1); verify_integer_multiplication_by_power_of_10(-1, -1); - integer_multiplication_by_power_of_10_test(49406564584124654, -340, - DBL_TRUE_MIN); - integer_multiplication_by_power_of_10_test(22250738585072014, -324, - DBL_MIN); - integer_multiplication_by_power_of_10_test(17976931348623158, 292, DBL_MAX); + integer_multiplication_by_power_of_10_test(49406564584124654, + -340, DBL_TRUE_MIN); + integer_multiplication_by_power_of_10_test(22250738585072014, + -324, DBL_MIN); + integer_multiplication_by_power_of_10_test(17976931348623158, 292, + DBL_MAX); // DBL_TRUE_MIN / 2 underflows to 0 - integer_multiplication_by_power_of_10_test(49406564584124654 / 2, -340, 0.); + integer_multiplication_by_power_of_10_test(49406564584124654 / 2, + -340, 0.); // DBL_TRUE_MIN / 2 + 0.0000000000000001e-324 rounds to DBL_TRUE_MIN - integer_multiplication_by_power_of_10_test(49406564584124654 / 2 + 1, -340, - DBL_TRUE_MIN); + integer_multiplication_by_power_of_10_test( + 49406564584124654 / 2 + 1, -340, DBL_TRUE_MIN); // DBL_MAX + 0.0000000000000001e308 overflows to infinity integer_multiplication_by_power_of_10_test( @@ -2192,14 +2200,22 @@ TEST_CASE("multiply_integer_and_power_of_10") { verify_integer_multiplication_by_power_of_10(1234567890123, 42); verify_integer_multiplication_by_power_of_10(12345678901234, 42); verify_integer_multiplication_by_power_of_10(123456789012345, 42); - verify_integer_multiplication_by_power_of_10(1234567890123456, 42); - verify_integer_multiplication_by_power_of_10(12345678901234567, 42); - verify_integer_multiplication_by_power_of_10(123456789012345678, 42); - verify_integer_multiplication_by_power_of_10(1234567890123456789, 42); - verify_integer_multiplication_by_power_of_10(12345678901234567890ULL, 42); + verify_integer_multiplication_by_power_of_10(1234567890123456, + 42); + verify_integer_multiplication_by_power_of_10(12345678901234567, + 42); + verify_integer_multiplication_by_power_of_10(123456789012345678, + 42); + verify_integer_multiplication_by_power_of_10(1234567890123456789, + 42); + verify_integer_multiplication_by_power_of_10( + 12345678901234567890ULL, 42); // ULLONG_MAX - verify_integer_multiplication_by_power_of_10(18446744073709551615ULL, 42); - verify_integer_multiplication_by_power_of_10(std::numeric_limits::max(), 42); - verify_integer_multiplication_by_power_of_10(std::numeric_limits::min(), 42); + verify_integer_multiplication_by_power_of_10( + 18446744073709551615ULL, 42); + verify_integer_multiplication_by_power_of_10( + std::numeric_limits::max(), 42); + verify_integer_multiplication_by_power_of_10( + std::numeric_limits::min(), 42); } } \ No newline at end of file