Get GNU MPFR and MPC tests to pass

This change fixes more issues with our scanf() function.
This commit is contained in:
Justine Tunney 2023-08-21 12:16:52 -07:00
parent 63a1636e1f
commit 6ef2a471e4
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
37 changed files with 389 additions and 865 deletions

View file

@ -306,37 +306,12 @@ TEST(strtoimax, testEndPtr) {
ASSERT_EQ(1, e - p);
}
TEST(strtoi128, testLimits) {
EXPECT_EQ(
((uint128_t)0xffffffffffffffff) << 64 | (uint128_t)0xffffffffffffffff,
strtoi128("-1", NULL, 0));
EXPECT_EQ(
((uint128_t)0x7fffffffffffffff) << 64 | (uint128_t)0xffffffffffffffff,
strtoi128("0x7fffffffffffffffffffffffffffffff", NULL, 0));
}
TEST(strtoi128, testOutsideLimit) {
errno = 0;
EXPECT_EQ(
((uint128_t)0x7fffffffffffffff) << 64 | (uint128_t)0xffffffffffffffff,
strtoi128("0x80000000000000000000000000000000", NULL, 0));
EXPECT_EQ(ERANGE, errno);
errno = 0;
EXPECT_EQ(((uint128_t)0x8000000000000000) << 64 | 0x0000000000000000,
strtoi128("-0x80000000000000000000000000000001", NULL, 0));
EXPECT_EQ(ERANGE, errno);
}
TEST(strtoul, neghex) {
errno = 0;
ASSERT_EQ(-16, (long)strtoul("0xfffffffffffffff0", NULL, 0));
EXPECT_EQ(0, errno);
}
TEST(strtoumax, testZero) {
EXPECT_EQ(UINTMAX_MIN, strtoumax("0", NULL, 0));
EXPECT_EQ(UINT128_MIN, strtou128("0", NULL, 0));
}
TEST(strtoumax, testDecimal) {
EXPECT_EQ(123, strtoumax("123", NULL, 0));
EXPECT_EQ(-123, strtoumax("-123", NULL, 0));
@ -354,18 +329,6 @@ TEST(strtoumax, testBinary) {
EXPECT_EQ(42, strtoumax("0b101010", NULL, 2));
}
TEST(strtou128, test128imum) {
EXPECT_EQ(UINT128_MAX,
strtou128("340282366920938463463374607431768211455", NULL, 0));
EXPECT_EQ(UINT128_MAX,
strtou128("0xffffffffffffffffffffffffffffffff", NULL, 0));
}
TEST(strtou128, testTwosBane) {
EXPECT_EQ(((uint128_t)0x8000000000000000) << 64 | 0x0000000000000000,
strtou128("0x80000000000000000000000000000000", NULL, 0));
}
TEST(wcstol, test) {
EXPECT_EQ(0, wcstol(L"", 0, 10));
EXPECT_EQ(0, wcstol(L"0", 0, 10));
@ -591,12 +554,4 @@ BENCH(atoi, bench) {
__expropriate(wcstoimax(__veil("r", L"100000000"), 0, 10)));
EZBENCH2("wcstoumax 10⁸", donothing,
__expropriate(wcstoimax(__veil("r", L"100000000"), 0, 10)));
EZBENCH2("strtoi128 10⁸", donothing,
__expropriate(strtoi128(__veil("r", "100000000"), 0, 10)));
EZBENCH2("strtou128 10⁸", donothing,
__expropriate(strtoi128(__veil("r", "100000000"), 0, 10)));
EZBENCH2("wcstoi128 10⁸", donothing,
__expropriate(wcstoi128(__veil("r", L"100000000"), 0, 10)));
EZBENCH2("wcstou128 10⁸", donothing,
__expropriate(wcstoi128(__veil("r", L"100000000"), 0, 10)));
}