Skip to content

Commit 9332361

Browse files
committed
Add in checks that specified precision is invalid
1 parent 80f02da commit 9332361

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/test_charconv_preservation.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ void test_invalid_to_chars(const std::array<T, N>& decimals)
7979
const auto r {to_chars(buffer, buffer + sizeof(buffer), decimals[i], chars_format::cohort_preserving_scientific)};
8080
BOOST_TEST(!r);
8181
}
82+
83+
for (std::size_t i {}; i < decimals.size(); ++i)
84+
{
85+
char buffer[64] {};
86+
const auto r {to_chars(buffer, buffer + sizeof(buffer), decimals[i], chars_format::cohort_preserving_scientific, 5)};
87+
BOOST_TEST(!r);
88+
}
8289
}
8390

8491
template <typename T>
@@ -180,5 +187,10 @@ int main()
180187
test_invalid_to_chars(decimals<decimal_fast64_t>);
181188
test_invalid_to_chars(decimals<decimal_fast128_t>);
182189

190+
// Specified precision is not allowed
191+
test_invalid_to_chars(decimals<decimal32_t>);
192+
test_invalid_to_chars(decimals<decimal64_t>);
193+
test_invalid_to_chars(decimals<decimal128_t>);
194+
183195
return boost::report_errors();
184196
}

0 commit comments

Comments
 (0)