@@ -23,7 +23,7 @@ static constexpr auto N = static_cast<std::size_t>(1024U >> 4U); // Number of tr
2323#if !defined(BOOST_DECIMAL_DISABLE_CLIB) && !(defined(__GNUC__) && __GNUC__ >= 13 && !defined(__aarch64__))
2424
2525template <typename T>
26- void test_value (T val, const char * result, chars_format fmt, int precision = - 1 )
26+ void test_value (T val, const char * result, chars_format fmt, int precision)
2727{
2828 char buffer[256 ] {};
2929 auto r = to_chars (buffer, buffer + sizeof (buffer), val, fmt, precision);
@@ -32,6 +32,16 @@ void test_value(T val, const char* result, chars_format fmt, int precision = -1)
3232 BOOST_TEST_CSTR_EQ (result, buffer);
3333}
3434
35+ template <typename T>
36+ void test_value (T val, const char * result, chars_format fmt)
37+ {
38+ char buffer[256 ] {};
39+ auto r = to_chars (buffer, buffer + sizeof (buffer), val, fmt);
40+ *r.ptr = ' \0 ' ;
41+ BOOST_TEST (r);
42+ BOOST_TEST_CSTR_EQ (result, buffer);
43+ }
44+
3545template <typename T>
3646void test_value (T val, const char * result)
3747{
@@ -764,6 +774,25 @@ void test_777()
764774 test_value (value3, " -2111000000" , chars_format::fixed, 0 );
765775}
766776
777+ template <typename T>
778+ void test_more_powers_10 ()
779+ {
780+ test_value (T{1 , -6 }, " 0.000001" , chars_format::fixed);
781+ test_value (T{1 , -5 }, " 0.00001" , chars_format::fixed);
782+ test_value (T{1 , -4 }, " 0.0001" , chars_format::fixed);
783+ test_value (T{1 , -3 }, " 0.001" , chars_format::fixed);
784+ test_value (T{1 , -2 }, " 0.01" , chars_format::fixed);
785+ test_value (T{1 , -1 }, " 0.1" , chars_format::fixed);
786+ test_value (T{1 , 0 }, " 1" , chars_format::fixed);
787+ test_value (T{1 , 1 }, " 10" , chars_format::fixed);
788+ test_value (T{1 , 2 }, " 100" , chars_format::fixed);
789+ test_value (T{1 , 3 }, " 1000" , chars_format::fixed);
790+ test_value (T{1 , 4 }, " 10000" , chars_format::fixed);
791+ test_value (T{1 , 5 }, " 100000" , chars_format::fixed);
792+ test_value (T{1 , 6 }, " 1000000" , chars_format::fixed);
793+ test_value (T{1 , 7 }, " 10000000" , chars_format::fixed);
794+ }
795+
767796int main ()
768797{
769798 test_non_finite_values<decimal32>();
@@ -874,6 +903,10 @@ int main()
874903 test_777<decimal64_fast>();
875904 test_777<decimal128_fast>();
876905
906+ test_more_powers_10<decimal32>();
907+ test_more_powers_10<decimal64>();
908+ test_more_powers_10<decimal128>();
909+
877910 return boost::report_errors ();
878911}
879912
0 commit comments