mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Set errno when out of range in strtoimax (#111)
This commit is contained in:
parent
f5da4efcaf
commit
8a6ac6dd63
5 changed files with 29 additions and 5 deletions
|
@ -53,9 +53,17 @@ TEST(strtoimax, testLimits) {
|
|||
strtoimax("0x7fffffffffffffffffffffffffffffff", NULL, 0));
|
||||
}
|
||||
|
||||
TEST(strtoimax, testTwosBane) {
|
||||
EXPECT_EQ(((uintmax_t)0x8000000000000000) << 64 | 0x0000000000000000,
|
||||
strtoimax("0x80000000000000000000000000000000", NULL, 0));
|
||||
TEST(strtoimax, testOutsideLimit) {
|
||||
errno = 0;
|
||||
EXPECT_EQ(
|
||||
((uintmax_t)0x7fffffffffffffff) << 64 | (uintmax_t)0xffffffffffffffff,
|
||||
strtoimax("0x80000000000000000000000000000000", NULL, 0));
|
||||
EXPECT_EQ(ERANGE, errno);
|
||||
errno = 0;
|
||||
EXPECT_EQ(
|
||||
((uintmax_t)0x8000000000000000) << 64 | 0x0000000000000000,
|
||||
strtoimax("-0x80000000000000000000000000000001", NULL, 0));
|
||||
EXPECT_EQ(ERANGE, errno);
|
||||
}
|
||||
|
||||
TEST(strtoul, neghex) {
|
||||
|
|
|
@ -46,3 +46,8 @@ TEST(strtoumax, testMaximum) {
|
|||
EXPECT_EQ(UINTMAX_MAX,
|
||||
strtoumax("0xffffffffffffffffffffffffffffffff", NULL, 0));
|
||||
}
|
||||
|
||||
TEST(strtoumax, testTwosBane) {
|
||||
EXPECT_EQ(((uintmax_t)0x8000000000000000) << 64 | 0x0000000000000000,
|
||||
strtoumax("0x80000000000000000000000000000000", NULL, 0));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue