@@ -220,6 +220,29 @@ TYPED_TEST_P(Parsing, MaxMinFloat) {
220220 EXPECT_EQ (float_negative_min.template As <float >(), -kFloatMin );
221221}
222222
223+ TYPED_TEST_P (Parsing, InfNanFloatDouble) {
224+ // May abort in test builds
225+ #ifdef NDEBUG
226+ using Value = std::decay_t <decltype (this ->kFromString (" " ))>;
227+ using Exception = typename Value::Exception;
228+
229+ constexpr float kFloatInf = std::numeric_limits<float >::infinity ();
230+ constexpr float kFloatNan = std::numeric_limits<float >::quiet_NaN ();
231+
232+ EXPECT_THROW (this ->kFromString (fmt::format (" [{}]" , kFloatInf ))[0 ].template As <float >(), Exception);
233+ EXPECT_THROW (this ->kFromString (fmt::format (" [{}]" , -kFloatInf ))[0 ].template As <float >(), Exception);
234+ EXPECT_THROW (this ->kFromString (fmt::format (" [{}]" , kFloatNan ))[0 ].template As <float >(), Exception);
235+ EXPECT_THROW (this ->kFromString (fmt::format (" [{}]" , -kFloatNan ))[0 ].template As <float >(), Exception);
236+
237+ constexpr double kDoubleInf = std::numeric_limits<double >::infinity ();
238+ constexpr double kDoubleNan = std::numeric_limits<double >::quiet_NaN ();
239+ EXPECT_THROW (this ->kFromString (fmt::format (" [{}]" , kDoubleInf ))[0 ].template As <double >(), Exception);
240+ EXPECT_THROW (this ->kFromString (fmt::format (" [{}]" , -kDoubleInf ))[0 ].template As <double >(), Exception);
241+ EXPECT_THROW (this ->kFromString (fmt::format (" [{}]" , kDoubleNan ))[0 ].template As <double >(), Exception);
242+ EXPECT_THROW (this ->kFromString (fmt::format (" [{}]" , -kDoubleNan ))[0 ].template As <double >(), Exception);
243+ #endif
244+ }
245+
223246TYPED_TEST_P (Parsing, UserProvidedCommonParser) {
224247 auto value = this ->kFromString (" [42]" )[0 ];
225248
@@ -394,6 +417,7 @@ REGISTER_TYPED_TEST_SUITE_P(
394417 UInt,
395418 IntOverflow,
396419 MaxMinFloat,
420+ InfNanFloatDouble,
397421 UserProvidedCommonParser,
398422
399423 ChronoDoubleSeconds,
0 commit comments