Skip to content

Commit a51aa7f

Browse files
committed
Add new interfaces testing
1 parent 0511600 commit a51aa7f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/test_from_chars.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ void test_non_finite_values()
162162

163163
const char* snan_str = "nan(snan)";
164164
auto r = from_chars(snan_str, snan_str + std::strlen(snan_str), val);
165+
BOOST_TEST(r);
165166
BOOST_TEST(isnan(val));
166167

167168
const char* qnan_str = "nan";
@@ -318,6 +319,17 @@ void test_from_chars_general_std()
318319

319320
#endif
320321

322+
template <typename T>
323+
void test_string_interface()
324+
{
325+
constexpr T correct_val {42};
326+
std::string str {"42"};
327+
T val;
328+
const auto r = from_chars(str, val);
329+
BOOST_TEST(r);
330+
BOOST_TEST_EQ(val, correct_val);
331+
}
332+
321333
int main()
322334
{
323335
test_from_chars_scientific<decimal32>();
@@ -362,12 +374,25 @@ int main()
362374
test_hex_values<decimal32_fast>();
363375
test_hex_values<decimal64_fast>();
364376

377+
test_string_interface<decimal32>();
378+
test_string_interface<decimal64>();
379+
test_string_interface<decimal32_fast>();
380+
test_string_interface<decimal64_fast>();
381+
365382
#if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH)
366383
test_from_chars_scientific<decimal128>();
367384
test_from_chars_fixed<decimal128>();
368385
test_from_chars_general<decimal128>();
369386
test_non_finite_values<decimal128>();
370387
test_hex_values<decimal128>();
388+
test_string_interface<decimal128>();
389+
390+
test_from_chars_scientific<decimal128_fast>();
391+
test_from_chars_fixed<decimal128_fast>();
392+
test_from_chars_general<decimal128_fast>();
393+
test_non_finite_values<decimal128_fast>();
394+
test_hex_values<decimal128_fast>();
395+
test_string_interface<decimal128_fast>();
371396
#endif
372397

373398
return boost::report_errors();

0 commit comments

Comments
 (0)