mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 08:46:49 +08:00
lint
This commit is contained in:
parent
d377c92e64
commit
8aed60912c
@ -2106,15 +2106,21 @@ void integer_multiplication_by_power_of_10_test(Int mantissa,
|
||||
}
|
||||
|
||||
template <typename Int>
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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<uint64_t>(49406564584124654, -340,
|
||||
DBL_TRUE_MIN);
|
||||
integer_multiplication_by_power_of_10_test<uint64_t>(22250738585072014, -324,
|
||||
DBL_MIN);
|
||||
integer_multiplication_by_power_of_10_test<uint64_t>(17976931348623158, 292, DBL_MAX);
|
||||
integer_multiplication_by_power_of_10_test<uint64_t>(49406564584124654,
|
||||
-340, DBL_TRUE_MIN);
|
||||
integer_multiplication_by_power_of_10_test<uint64_t>(22250738585072014,
|
||||
-324, DBL_MIN);
|
||||
integer_multiplication_by_power_of_10_test<uint64_t>(17976931348623158, 292,
|
||||
DBL_MAX);
|
||||
|
||||
// DBL_TRUE_MIN / 2 underflows to 0
|
||||
integer_multiplication_by_power_of_10_test<uint64_t>(49406564584124654 / 2, -340, 0.);
|
||||
integer_multiplication_by_power_of_10_test<uint64_t>(49406564584124654 / 2,
|
||||
-340, 0.);
|
||||
|
||||
// DBL_TRUE_MIN / 2 + 0.0000000000000001e-324 rounds to DBL_TRUE_MIN
|
||||
integer_multiplication_by_power_of_10_test<uint64_t>(49406564584124654 / 2 + 1, -340,
|
||||
DBL_TRUE_MIN);
|
||||
integer_multiplication_by_power_of_10_test<uint64_t>(
|
||||
49406564584124654 / 2 + 1, -340, DBL_TRUE_MIN);
|
||||
|
||||
// DBL_MAX + 0.0000000000000001e308 overflows to infinity
|
||||
integer_multiplication_by_power_of_10_test<uint64_t>(
|
||||
@ -2192,14 +2200,22 @@ TEST_CASE("multiply_integer_and_power_of_10") {
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(1234567890123, 42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(12345678901234, 42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(123456789012345, 42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(1234567890123456, 42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(12345678901234567, 42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(123456789012345678, 42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(1234567890123456789, 42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(12345678901234567890ULL, 42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(1234567890123456,
|
||||
42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(12345678901234567,
|
||||
42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(123456789012345678,
|
||||
42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(1234567890123456789,
|
||||
42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(
|
||||
12345678901234567890ULL, 42);
|
||||
// ULLONG_MAX
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(18446744073709551615ULL, 42);
|
||||
verify_integer_multiplication_by_power_of_10<int64_t>(std::numeric_limits<int64_t>::max(), 42);
|
||||
verify_integer_multiplication_by_power_of_10<int64_t>(std::numeric_limits<int64_t>::min(), 42);
|
||||
verify_integer_multiplication_by_power_of_10<uint64_t>(
|
||||
18446744073709551615ULL, 42);
|
||||
verify_integer_multiplication_by_power_of_10<int64_t>(
|
||||
std::numeric_limits<int64_t>::max(), 42);
|
||||
verify_integer_multiplication_by_power_of_10<int64_t>(
|
||||
std::numeric_limits<int64_t>::min(), 42);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user