Skip to content

Commit f29dec7

Browse files
committed
test using the limits struct
1 parent 3d16a3f commit f29dec7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/test_to_chars.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

2525
template <typename T>
26-
void test_value(T val, const char* result, chars_format fmt = boost::decimal::chars_format::general, int precision = -1)
26+
void test_value(T val, const char* result, chars_format fmt, int precision = -1)
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 = boost::decimal::ch
3232
BOOST_TEST_CSTR_EQ(result, buffer);
3333
}
3434

35+
template <typename T>
36+
void test_value(T val, const char* result)
37+
{
38+
char buffer[boost::decimal::limits<T>::max_chars] {};
39+
auto r = to_chars(buffer, buffer + sizeof(buffer), val, chars_format::general);
40+
*r.ptr = '\0';
41+
BOOST_TEST(r);
42+
BOOST_TEST_CSTR_EQ(result, buffer);
43+
}
44+
3545
template <typename T>
3646
void test_non_finite_values()
3747
{

0 commit comments

Comments
 (0)