mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-09-19 15:19:54 +00:00
test: check if an exception is thrown by overflow
This commit is contained in:
parent
12d0dbc6f4
commit
d6efdf7d9e
@ -176,3 +176,10 @@ BOOST_AUTO_TEST_CASE(test_nan)
|
||||
BOOST_CHECK(std::isnan(r.unwrap().first));
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_overflow)
|
||||
{
|
||||
std::istringstream float_overflow (std::string("float-overflow = 1.0e+1024"));
|
||||
BOOST_CHECK_THROW(toml::parse(float_overflow ), toml::syntax_error);
|
||||
// istringstream >> float does not set failbit in case of underflow.
|
||||
}
|
||||
|
@ -90,3 +90,15 @@ BOOST_AUTO_TEST_CASE(test_bin_value)
|
||||
TOML11_TEST_PARSE_EQUAL_VALUE(parse_value<toml::value>, "0b01_00_00", value(16));
|
||||
TOML11_TEST_PARSE_EQUAL_VALUE(parse_value<toml::value>, "0b111111", value(63));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_integer_overflow)
|
||||
{
|
||||
std::istringstream dec_overflow(std::string("dec-overflow = 9223372036854775808"));
|
||||
std::istringstream hex_overflow(std::string("hex-overflow = 0x1_00000000_00000000"));
|
||||
std::istringstream oct_overflow(std::string("oct-overflow = 0o1_000_000_000_000_000_000_000"));
|
||||
std::istringstream bin_overflow(std::string("bin-overflow = 0b1_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000"));
|
||||
BOOST_CHECK_THROW(toml::parse(dec_overflow), toml::syntax_error);
|
||||
BOOST_CHECK_THROW(toml::parse(hex_overflow), toml::syntax_error);
|
||||
BOOST_CHECK_THROW(toml::parse(oct_overflow), toml::syntax_error);
|
||||
BOOST_CHECK_THROW(toml::parse(bin_overflow), toml::syntax_error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user