Skip to content

Commit c2bf7c5

Browse files
authored
Merge pull request #776 from cppalliance/coverage
Improve Coverage
2 parents d470174 + dfa6346 commit c2bf7c5

File tree

4 files changed

+47
-45
lines changed

4 files changed

+47
-45
lines changed

include/boost/decimal/detail/io.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ auto operator<<(std::basic_ostream<charT, traits>& os, const DecimalType& d)
127127

128128
if (BOOST_DECIMAL_UNLIKELY(!r))
129129
{
130-
errno = static_cast<int>(r.ec);
130+
errno = static_cast<int>(r.ec); // LCOV_EXCL_LINE
131131
}
132132

133133
*r.ptr = '\0';

test/compare_dec128_and_fast.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void test_add()
7474

7575
std::cerr << strm.str() << std::endl;
7676
// LCOV_EXCL_STOP
77-
}
77+
} // LCOV_EXCL_LINE
7878
}
7979

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

110110
std::cerr << strm.str() << std::endl;
111111
// LCOV_EXCL_STOP
112-
}
112+
} // LCOV_EXCL_LINE
113113
}
114114
}
115115

@@ -147,7 +147,7 @@ void test_sub()
147147

148148
std::cerr << strm.str() << std::endl;
149149
// LCOV_EXCL_STOP
150-
}
150+
} // LCOV_EXCL_LINE
151151
}
152152

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

183183
std::cerr << strm.str() << std::endl;
184184
// LCOV_EXCL_STOP
185-
}
185+
} // LCOV_EXCL_LINE
186186
}
187187
}
188188

test/random_decimal128_math.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ void random_multiplication(T lower, T upper)
252252
if (val1 * val2 == 0)
253253
{
254254
// Integers don't have signed 0 but decimal does
255-
continue;
255+
continue; // LCOV_EXCL_LINE
256256
}
257257

258258
if (!BOOST_TEST_EQ(res_int, val1 * val2))

test/test_to_chars.cpp

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -468,52 +468,54 @@ void test_buffer_overflow()
468468
template <typename T>
469469
void zero_test()
470470
{
471+
std::uniform_real_distribution<double> dist;
472+
471473
constexpr T val {0, 0};
472474

473475
// General should always be the same
474476
for (int precision = 0; precision < 50; ++precision)
475477
{
476-
test_value(val, "0.0e+00", chars_format::general, precision);
478+
test_value(val * T{dist(rng)}, "0.0e+00", chars_format::general, precision);
477479
}
478480

479-
test_value(val, "0e+00", chars_format::scientific, 0);
480-
test_value(val, "0.0e+00", chars_format::scientific, 1);
481-
test_value(val, "0.00e+00", chars_format::scientific, 2);
482-
test_value(val, "0.000e+00", chars_format::scientific, 3);
483-
test_value(val, "0.0000e+00", chars_format::scientific, 4);
484-
test_value(val, "0.00000e+00", chars_format::scientific, 5);
485-
test_value(val, "0.000000e+00", chars_format::scientific, 6);
486-
test_value(val, "0.0000000e+00", chars_format::scientific, 7);
487-
test_value(val, "0.00000000e+00", chars_format::scientific, 8);
488-
test_value(val, "0.000000000e+00", chars_format::scientific, 9);
489-
test_value(val, "0.0000000000e+00", chars_format::scientific, 10);
490-
test_value(val, "0.00000000000000000000000000000000000000000000000000e+00", chars_format::scientific, 50);
491-
492-
test_value(val, "0p+00", chars_format::hex, 0);
493-
test_value(val, "0.0p+00", chars_format::hex, 1);
494-
test_value(val, "0.00p+00", chars_format::hex, 2);
495-
test_value(val, "0.000p+00", chars_format::hex, 3);
496-
test_value(val, "0.0000p+00", chars_format::hex, 4);
497-
test_value(val, "0.00000p+00", chars_format::hex, 5);
498-
test_value(val, "0.000000p+00", chars_format::hex, 6);
499-
test_value(val, "0.0000000p+00", chars_format::hex, 7);
500-
test_value(val, "0.00000000p+00", chars_format::hex, 8);
501-
test_value(val, "0.000000000p+00", chars_format::hex, 9);
502-
test_value(val, "0.0000000000p+00", chars_format::hex, 10);
503-
test_value(val, "0.00000000000000000000000000000000000000000000000000p+00", chars_format::hex, 50);
504-
505-
test_value(val, "0", chars_format::fixed, 0);
506-
test_value(val, "0.0", chars_format::fixed, 1);
507-
test_value(val, "0.00", chars_format::fixed, 2);
508-
test_value(val, "0.000", chars_format::fixed, 3);
509-
test_value(val, "0.0000", chars_format::fixed, 4);
510-
test_value(val, "0.00000", chars_format::fixed, 5);
511-
test_value(val, "0.000000", chars_format::fixed, 6);
512-
test_value(val, "0.0000000", chars_format::fixed, 7);
513-
test_value(val, "0.00000000", chars_format::fixed, 8);
514-
test_value(val, "0.000000000", chars_format::fixed, 9);
515-
test_value(val, "0.0000000000", chars_format::fixed, 10);
516-
test_value(val, "0.00000000000000000000000000000000000000000000000000", chars_format::fixed, 50);
481+
test_value(val * T{dist(rng)}, "0e+00", chars_format::scientific, 0);
482+
test_value(val * T{dist(rng)}, "0.0e+00", chars_format::scientific, 1);
483+
test_value(val * T{dist(rng)}, "0.00e+00", chars_format::scientific, 2);
484+
test_value(val * T{dist(rng)}, "0.000e+00", chars_format::scientific, 3);
485+
test_value(val * T{dist(rng)}, "0.0000e+00", chars_format::scientific, 4);
486+
test_value(val * T{dist(rng)}, "0.00000e+00", chars_format::scientific, 5);
487+
test_value(val * T{dist(rng)}, "0.000000e+00", chars_format::scientific, 6);
488+
test_value(val * T{dist(rng)}, "0.0000000e+00", chars_format::scientific, 7);
489+
test_value(val * T{dist(rng)}, "0.00000000e+00", chars_format::scientific, 8);
490+
test_value(val * T{dist(rng)}, "0.000000000e+00", chars_format::scientific, 9);
491+
test_value(val * T{dist(rng)}, "0.0000000000e+00", chars_format::scientific, 10);
492+
test_value(val * T{dist(rng)}, "0.00000000000000000000000000000000000000000000000000e+00", chars_format::scientific, 50);
493+
494+
test_value(val * T{dist(rng)}, "0p+00", chars_format::hex, 0);
495+
test_value(val * T{dist(rng)}, "0.0p+00", chars_format::hex, 1);
496+
test_value(val * T{dist(rng)}, "0.00p+00", chars_format::hex, 2);
497+
test_value(val * T{dist(rng)}, "0.000p+00", chars_format::hex, 3);
498+
test_value(val * T{dist(rng)}, "0.0000p+00", chars_format::hex, 4);
499+
test_value(val * T{dist(rng)}, "0.00000p+00", chars_format::hex, 5);
500+
test_value(val * T{dist(rng)}, "0.000000p+00", chars_format::hex, 6);
501+
test_value(val * T{dist(rng)}, "0.0000000p+00", chars_format::hex, 7);
502+
test_value(val * T{dist(rng)}, "0.00000000p+00", chars_format::hex, 8);
503+
test_value(val * T{dist(rng)}, "0.000000000p+00", chars_format::hex, 9);
504+
test_value(val * T{dist(rng)}, "0.0000000000p+00", chars_format::hex, 10);
505+
test_value(val * T{dist(rng)}, "0.00000000000000000000000000000000000000000000000000p+00", chars_format::hex, 50);
506+
507+
test_value(val * T{dist(rng)}, "0", chars_format::fixed, 0);
508+
test_value(val * T{dist(rng)}, "0.0", chars_format::fixed, 1);
509+
test_value(val * T{dist(rng)}, "0.00", chars_format::fixed, 2);
510+
test_value(val * T{dist(rng)}, "0.000", chars_format::fixed, 3);
511+
test_value(val * T{dist(rng)}, "0.0000", chars_format::fixed, 4);
512+
test_value(val * T{dist(rng)}, "0.00000", chars_format::fixed, 5);
513+
test_value(val * T{dist(rng)}, "0.000000", chars_format::fixed, 6);
514+
test_value(val * T{dist(rng)}, "0.0000000", chars_format::fixed, 7);
515+
test_value(val * T{dist(rng)}, "0.00000000", chars_format::fixed, 8);
516+
test_value(val * T{dist(rng)}, "0.000000000", chars_format::fixed, 9);
517+
test_value(val * T{dist(rng)}, "0.0000000000", chars_format::fixed, 10);
518+
test_value(val * T{dist(rng)}, "0.00000000000000000000000000000000000000000000000000", chars_format::fixed, 50);
517519
}
518520

519521
// See: https://github.com/cppalliance/decimal/issues/434

0 commit comments

Comments
 (0)