Skip to content

Commit ce00fe0

Browse files
committed
Add testing of invalid path
1 parent 40c6a45 commit ce00fe0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/test_from_string.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,31 @@ void test()
7979
inline void test_overflow_path()
8080
{
8181
const std::string str {"INF"};
82+
83+
#ifndef BOOST_DECIMAL_DISABLE_EXCEPTIONS
84+
8285
BOOST_TEST_THROWS(recover_value<decimal32_t>(str, nullptr), std::out_of_range);
86+
87+
#else
88+
89+
BOOST_TEST(isnan(recover_value<decimal32_t>(str, nullptr)));
90+
91+
#endif
92+
}
93+
94+
inline void test_invalid_path()
95+
{
96+
const std::string str {"JUNK"};
97+
98+
#ifndef BOOST_DECIMAL_DISABLE_EXCEPTIONS
99+
100+
BOOST_TEST_THROWS(recover_value<decimal32_t>(str, nullptr), std::invalid_argument);
101+
102+
#else
103+
104+
BOOST_TEST(isnan(recover_value<decimal32_t>(str, nullptr)));
105+
106+
#endif
83107
}
84108

85109
int main()
@@ -92,6 +116,7 @@ int main()
92116
test<decimal_fast128_t>();
93117

94118
test_overflow_path();
119+
test_invalid_path();
95120

96121
return boost::report_errors();
97122
}

0 commit comments

Comments
 (0)