@@ -468,52 +468,54 @@ void test_buffer_overflow()
468468template <typename T>
469469void 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