mirror of
https://github.com/fmtlib/fmt.git
synced 2026-08-03 20:14:20 +02:00
Add overflow check
This commit is contained in:
@@ -63,6 +63,9 @@ TEST(scan_test, read_hex) {
|
||||
unsigned n = 0;
|
||||
fmt::scan("2a", "{:x}", n);
|
||||
EXPECT_EQ(n, 42);
|
||||
auto num_digits = std::numeric_limits<unsigned>::digits / 4;
|
||||
EXPECT_THROW_MSG(fmt::scan(fmt::format("1{:0{}}", 0, num_digits), "{:x}", n),
|
||||
fmt::format_error, "number is too big");
|
||||
}
|
||||
|
||||
TEST(scan_test, read_string) {
|
||||
|
||||
Reference in New Issue
Block a user