mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-08 13:50:06 +00:00
test: check if a large bin ints are parsed
This commit is contained in:
parent
51587338cd
commit
fd969a679b
@ -84,6 +84,22 @@ BOOST_AUTO_TEST_CASE(test_bin_value)
|
||||
TOML11_TEST_PARSE_EQUAL_VALUE(parse_value<toml::value>, "0b010000", value(16));
|
||||
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));
|
||||
|
||||
TOML11_TEST_PARSE_EQUAL_VALUE(parse_value<toml::value>,
|
||||
"0b1000_1000_1000_1000_1000_1000_1000_1000_1000_1000_1000_1000_1000_1000_1000",
|
||||
// 1 0 0 0
|
||||
// 0 C 8 4
|
||||
value(0x0888888888888888));
|
||||
TOML11_TEST_PARSE_EQUAL_VALUE(parse_value<toml::value>,
|
||||
"0b01111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111",
|
||||
// 1 0 0 0
|
||||
// 0 C 8 4
|
||||
value(0x7FFFFFFFFFFFFFFF));
|
||||
TOML11_TEST_PARSE_EQUAL_VALUE(parse_value<toml::value>,
|
||||
"0b00000000_01111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111",
|
||||
// 1 0 0 0
|
||||
// 0 C 8 4
|
||||
value(0x7FFFFFFFFFFFFFFF));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_integer_overflow)
|
||||
@ -91,7 +107,8 @@ 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"));
|
||||
// 64 56 48 40 32 24 16 8
|
||||
std::istringstream bin_overflow(std::string("bin-overflow = 0b10000000_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);
|
||||
|
Loading…
Reference in New Issue
Block a user