Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/boost/decimal/detail/io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ auto operator<<(std::basic_ostream<charT, traits>& os, const DecimalType& d)

if (BOOST_DECIMAL_UNLIKELY(!r))
{
errno = static_cast<int>(r.ec);
errno = static_cast<int>(r.ec); // LCOV_EXCL_LINE
}

*r.ptr = '\0';
Expand Down
8 changes: 4 additions & 4 deletions test/compare_dec128_and_fast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void test_add()

std::cerr << strm.str() << std::endl;
// LCOV_EXCL_STOP
}
} // LCOV_EXCL_LINE
}

std::uniform_real_distribution<double> small_vals(0.0, 1.0);
Expand Down Expand Up @@ -109,7 +109,7 @@ void test_add()

std::cerr << strm.str() << std::endl;
// LCOV_EXCL_STOP
}
} // LCOV_EXCL_LINE
}
}

Expand Down Expand Up @@ -147,7 +147,7 @@ void test_sub()

std::cerr << strm.str() << std::endl;
// LCOV_EXCL_STOP
}
} // LCOV_EXCL_LINE
}

std::uniform_real_distribution<double> small_vals(0.0, 1.0);
Expand Down Expand Up @@ -182,7 +182,7 @@ void test_sub()

std::cerr << strm.str() << std::endl;
// LCOV_EXCL_STOP
}
} // LCOV_EXCL_LINE
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/random_decimal128_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
80 changes: 41 additions & 39 deletions test/test_to_chars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,52 +468,54 @@ void test_buffer_overflow()
template <typename T>
void zero_test()
{
std::uniform_real_distribution<double> 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
Expand Down
Loading