Fix int parsing with base 2 and 16 (#107)

This commit is contained in:
Alison Winters 2021-03-06 21:12:32 -08:00 committed by GitHub
parent fb7b7c6e21
commit 813e11b90b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 6 deletions

View file

@ -29,9 +29,15 @@ TEST(strtoumax, testDecimal) {
}
TEST(strtoumax, testHex) {
EXPECT_EQ(255, strtoumax("0xff", NULL, 0));
EXPECT_EQ(255, strtoumax("0xff", NULL, 16));
}
TEST(strtoumax, testOctal) {
EXPECT_EQ(123, strtoumax("0173", NULL, 0));
EXPECT_EQ(123, strtoumax("0173", NULL, 8));
}
TEST(strtoumax, testBinary) {
EXPECT_EQ(42, strtoumax("0b101010", NULL, 0));
EXPECT_EQ(42, strtoumax("0b101010", NULL, 2));
}
TEST(strtoumax, testMaximum) {