Skip to content

Commit 80f02da

Browse files
committed
Test invalid to_chars for fast types
1 parent 6fcbde7 commit 80f02da

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/test_charconv_preservation.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ void test_invalid_values(const std::array<T, N>& strings)
7070
}
7171
}
7272

73+
template <typename T, std::size_t N>
74+
void test_invalid_to_chars(const std::array<T, N>& decimals)
75+
{
76+
for (std::size_t i {}; i < decimals.size(); ++i)
77+
{
78+
char buffer[64] {};
79+
const auto r {to_chars(buffer, buffer + sizeof(buffer), decimals[i], chars_format::cohort_preserving_scientific)};
80+
BOOST_TEST(!r);
81+
}
82+
}
83+
7384
template <typename T>
7485
const std::array<T, 7> decimals = {
7586
T{3, 2},
@@ -165,6 +176,9 @@ int main()
165176
test_invalid_values<decimal_fast32_t>(strings);
166177
test_invalid_values<decimal_fast64_t>(decimals_with_exp_strings);
167178
test_invalid_values<decimal_fast128_t>(negative_values_strings);
179+
test_invalid_to_chars(decimals<decimal_fast32_t>);
180+
test_invalid_to_chars(decimals<decimal_fast64_t>);
181+
test_invalid_to_chars(decimals<decimal_fast128_t>);
168182

169183
return boost::report_errors();
170184
}

0 commit comments

Comments
 (0)