diff --git a/include/boost/decimal/detail/io.hpp b/include/boost/decimal/detail/io.hpp index e1e4ab9be..1689ade96 100644 --- a/include/boost/decimal/detail/io.hpp +++ b/include/boost/decimal/detail/io.hpp @@ -127,7 +127,7 @@ auto operator<<(std::basic_ostream& os, const DecimalType& d) if (BOOST_DECIMAL_UNLIKELY(!r)) { - errno = static_cast(r.ec); + errno = static_cast(r.ec); // LCOV_EXCL_LINE } *r.ptr = '\0'; diff --git a/test/compare_dec128_and_fast.cpp b/test/compare_dec128_and_fast.cpp index d07d1b063..cda559ada 100644 --- a/test/compare_dec128_and_fast.cpp +++ b/test/compare_dec128_and_fast.cpp @@ -74,7 +74,7 @@ void test_add() std::cerr << strm.str() << std::endl; // LCOV_EXCL_STOP - } + } // LCOV_EXCL_LINE } std::uniform_real_distribution small_vals(0.0, 1.0); @@ -109,7 +109,7 @@ void test_add() std::cerr << strm.str() << std::endl; // LCOV_EXCL_STOP - } + } // LCOV_EXCL_LINE } } @@ -147,7 +147,7 @@ void test_sub() std::cerr << strm.str() << std::endl; // LCOV_EXCL_STOP - } + } // LCOV_EXCL_LINE } std::uniform_real_distribution small_vals(0.0, 1.0); @@ -182,7 +182,7 @@ void test_sub() std::cerr << strm.str() << std::endl; // LCOV_EXCL_STOP - } + } // LCOV_EXCL_LINE } } diff --git a/test/random_decimal128_math.cpp b/test/random_decimal128_math.cpp index 29d459768..ba53beaac 100644 --- a/test/random_decimal128_math.cpp +++ b/test/random_decimal128_math.cpp @@ -252,7 +252,7 @@ void random_multiplication(T lower, T upper) if (val1 * val2 == 0) { // Integers don't have signed 0 but decimal does - continue; + continue; // LCOV_EXCL_LINE } if (!BOOST_TEST_EQ(res_int, val1 * val2)) diff --git a/test/test_to_chars.cpp b/test/test_to_chars.cpp index c9b2ee4e3..a66f102ee 100644 --- a/test/test_to_chars.cpp +++ b/test/test_to_chars.cpp @@ -468,52 +468,54 @@ void test_buffer_overflow() template void zero_test() { + std::uniform_real_distribution dist; + constexpr T val {0, 0}; // General should always be the same for (int precision = 0; precision < 50; ++precision) { - test_value(val, "0.0e+00", chars_format::general, precision); + test_value(val * T{dist(rng)}, "0.0e+00", chars_format::general, precision); } - test_value(val, "0e+00", chars_format::scientific, 0); - test_value(val, "0.0e+00", chars_format::scientific, 1); - test_value(val, "0.00e+00", chars_format::scientific, 2); - test_value(val, "0.000e+00", chars_format::scientific, 3); - test_value(val, "0.0000e+00", chars_format::scientific, 4); - test_value(val, "0.00000e+00", chars_format::scientific, 5); - test_value(val, "0.000000e+00", chars_format::scientific, 6); - test_value(val, "0.0000000e+00", chars_format::scientific, 7); - test_value(val, "0.00000000e+00", chars_format::scientific, 8); - test_value(val, "0.000000000e+00", chars_format::scientific, 9); - test_value(val, "0.0000000000e+00", chars_format::scientific, 10); - test_value(val, "0.00000000000000000000000000000000000000000000000000e+00", chars_format::scientific, 50); - - test_value(val, "0p+00", chars_format::hex, 0); - test_value(val, "0.0p+00", chars_format::hex, 1); - test_value(val, "0.00p+00", chars_format::hex, 2); - test_value(val, "0.000p+00", chars_format::hex, 3); - test_value(val, "0.0000p+00", chars_format::hex, 4); - test_value(val, "0.00000p+00", chars_format::hex, 5); - test_value(val, "0.000000p+00", chars_format::hex, 6); - test_value(val, "0.0000000p+00", chars_format::hex, 7); - test_value(val, "0.00000000p+00", chars_format::hex, 8); - test_value(val, "0.000000000p+00", chars_format::hex, 9); - test_value(val, "0.0000000000p+00", chars_format::hex, 10); - test_value(val, "0.00000000000000000000000000000000000000000000000000p+00", chars_format::hex, 50); - - test_value(val, "0", chars_format::fixed, 0); - test_value(val, "0.0", chars_format::fixed, 1); - test_value(val, "0.00", chars_format::fixed, 2); - test_value(val, "0.000", chars_format::fixed, 3); - test_value(val, "0.0000", chars_format::fixed, 4); - test_value(val, "0.00000", chars_format::fixed, 5); - test_value(val, "0.000000", chars_format::fixed, 6); - test_value(val, "0.0000000", chars_format::fixed, 7); - test_value(val, "0.00000000", chars_format::fixed, 8); - test_value(val, "0.000000000", chars_format::fixed, 9); - test_value(val, "0.0000000000", chars_format::fixed, 10); - test_value(val, "0.00000000000000000000000000000000000000000000000000", chars_format::fixed, 50); + test_value(val * T{dist(rng)}, "0e+00", chars_format::scientific, 0); + test_value(val * T{dist(rng)}, "0.0e+00", chars_format::scientific, 1); + test_value(val * T{dist(rng)}, "0.00e+00", chars_format::scientific, 2); + test_value(val * T{dist(rng)}, "0.000e+00", chars_format::scientific, 3); + test_value(val * T{dist(rng)}, "0.0000e+00", chars_format::scientific, 4); + test_value(val * T{dist(rng)}, "0.00000e+00", chars_format::scientific, 5); + test_value(val * T{dist(rng)}, "0.000000e+00", chars_format::scientific, 6); + test_value(val * T{dist(rng)}, "0.0000000e+00", chars_format::scientific, 7); + test_value(val * T{dist(rng)}, "0.00000000e+00", chars_format::scientific, 8); + test_value(val * T{dist(rng)}, "0.000000000e+00", chars_format::scientific, 9); + test_value(val * T{dist(rng)}, "0.0000000000e+00", chars_format::scientific, 10); + test_value(val * T{dist(rng)}, "0.00000000000000000000000000000000000000000000000000e+00", chars_format::scientific, 50); + + test_value(val * T{dist(rng)}, "0p+00", chars_format::hex, 0); + test_value(val * T{dist(rng)}, "0.0p+00", chars_format::hex, 1); + test_value(val * T{dist(rng)}, "0.00p+00", chars_format::hex, 2); + test_value(val * T{dist(rng)}, "0.000p+00", chars_format::hex, 3); + test_value(val * T{dist(rng)}, "0.0000p+00", chars_format::hex, 4); + test_value(val * T{dist(rng)}, "0.00000p+00", chars_format::hex, 5); + test_value(val * T{dist(rng)}, "0.000000p+00", chars_format::hex, 6); + test_value(val * T{dist(rng)}, "0.0000000p+00", chars_format::hex, 7); + test_value(val * T{dist(rng)}, "0.00000000p+00", chars_format::hex, 8); + test_value(val * T{dist(rng)}, "0.000000000p+00", chars_format::hex, 9); + test_value(val * T{dist(rng)}, "0.0000000000p+00", chars_format::hex, 10); + test_value(val * T{dist(rng)}, "0.00000000000000000000000000000000000000000000000000p+00", chars_format::hex, 50); + + test_value(val * T{dist(rng)}, "0", chars_format::fixed, 0); + test_value(val * T{dist(rng)}, "0.0", chars_format::fixed, 1); + test_value(val * T{dist(rng)}, "0.00", chars_format::fixed, 2); + test_value(val * T{dist(rng)}, "0.000", chars_format::fixed, 3); + test_value(val * T{dist(rng)}, "0.0000", chars_format::fixed, 4); + test_value(val * T{dist(rng)}, "0.00000", chars_format::fixed, 5); + test_value(val * T{dist(rng)}, "0.000000", chars_format::fixed, 6); + test_value(val * T{dist(rng)}, "0.0000000", chars_format::fixed, 7); + test_value(val * T{dist(rng)}, "0.00000000", chars_format::fixed, 8); + test_value(val * T{dist(rng)}, "0.000000000", chars_format::fixed, 9); + test_value(val * T{dist(rng)}, "0.0000000000", chars_format::fixed, 10); + test_value(val * T{dist(rng)}, "0.00000000000000000000000000000000000000000000000000", chars_format::fixed, 50); } // See: https://github.com/cppalliance/decimal/issues/434