[libc] Fix type errors on Windows

Fix the errors caused by having some numbers too large for a 32 bit
number in the tests for windows. Also fix the base causing some type
confusion.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D108653
This commit is contained in:
Michael Jones 2021-08-24 18:38:40 +00:00
parent 204038d52e
commit 6bbfd6a9c1
4 changed files with 18 additions and 18 deletions

View File

@ -46,18 +46,18 @@ TEST(LlvmLibcStrToLTest, CleanBaseTenDecode) {
ASSERT_EQ(errno, 0); ASSERT_EQ(errno, 0);
EXPECT_EQ(str_end - negative, ptrdiff_t(4)); EXPECT_EQ(str_end - negative, ptrdiff_t(4));
const char *big_number = "123456789012345"; const char *big_number = "1234567890";
errno = 0; errno = 0;
ASSERT_EQ(__llvm_libc::strtol(big_number, &str_end, 10), 123456789012345l); ASSERT_EQ(__llvm_libc::strtol(big_number, &str_end, 10), 1234567890l);
ASSERT_EQ(errno, 0); ASSERT_EQ(errno, 0);
EXPECT_EQ(str_end - big_number, ptrdiff_t(15)); EXPECT_EQ(str_end - big_number, ptrdiff_t(10));
const char *big_negative_number = "-123456789012345"; const char *big_negative_number = "-1234567890";
errno = 0; errno = 0;
ASSERT_EQ(__llvm_libc::strtol(big_negative_number, &str_end, 10), ASSERT_EQ(__llvm_libc::strtol(big_negative_number, &str_end, 10),
-123456789012345l); -1234567890l);
ASSERT_EQ(errno, 0); ASSERT_EQ(errno, 0);
EXPECT_EQ(str_end - big_negative_number, ptrdiff_t(16)); EXPECT_EQ(str_end - big_negative_number, ptrdiff_t(11));
const char *too_big_number = "123456789012345678901"; const char *too_big_number = "123456789012345678901";
errno = 0; errno = 0;
@ -155,7 +155,7 @@ static char int_to_b36_char(int input) {
TEST(LlvmLibcStrToLTest, DecodeInOtherBases) { TEST(LlvmLibcStrToLTest, DecodeInOtherBases) {
char small_string[4] = {'\0', '\0', '\0', '\0'}; char small_string[4] = {'\0', '\0', '\0', '\0'};
for (unsigned int base = 2; base <= 36; ++base) { for (long base = 2; base <= 36; ++base) {
for (long first_digit = 0; first_digit <= 36; ++first_digit) { for (long first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit); small_string[0] = int_to_b36_char(first_digit);
if (first_digit < base) { if (first_digit < base) {
@ -171,7 +171,7 @@ TEST(LlvmLibcStrToLTest, DecodeInOtherBases) {
} }
} }
for (unsigned int base = 2; base <= 36; ++base) { for (long base = 2; base <= 36; ++base) {
for (long first_digit = 0; first_digit <= 36; ++first_digit) { for (long first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit); small_string[0] = int_to_b36_char(first_digit);
for (long second_digit = 0; second_digit <= 36; ++second_digit) { for (long second_digit = 0; second_digit <= 36; ++second_digit) {
@ -195,7 +195,7 @@ TEST(LlvmLibcStrToLTest, DecodeInOtherBases) {
} }
} }
for (unsigned int base = 2; base <= 36; ++base) { for (long base = 2; base <= 36; ++base) {
for (long first_digit = 0; first_digit <= 36; ++first_digit) { for (long first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit); small_string[0] = int_to_b36_char(first_digit);
for (long second_digit = 0; second_digit <= 36; ++second_digit) { for (long second_digit = 0; second_digit <= 36; ++second_digit) {

View File

@ -179,7 +179,7 @@ static char int_to_b36_char(int input) {
TEST(LlvmLibcStrToLLTest, DecodeInOtherBases) { TEST(LlvmLibcStrToLLTest, DecodeInOtherBases) {
char small_string[4] = {'\0', '\0', '\0', '\0'}; char small_string[4] = {'\0', '\0', '\0', '\0'};
for (unsigned int base = 2; base <= 36; ++base) { for (long long base = 2; base <= 36; ++base) {
for (long long first_digit = 0; first_digit <= 36; ++first_digit) { for (long long first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit); small_string[0] = int_to_b36_char(first_digit);
if (first_digit < base) { if (first_digit < base) {
@ -195,7 +195,7 @@ TEST(LlvmLibcStrToLLTest, DecodeInOtherBases) {
} }
} }
for (unsigned int base = 2; base <= 36; ++base) { for (long long base = 2; base <= 36; ++base) {
for (long long first_digit = 0; first_digit <= 36; ++first_digit) { for (long long first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit); small_string[0] = int_to_b36_char(first_digit);
for (long long second_digit = 0; second_digit <= 36; ++second_digit) { for (long long second_digit = 0; second_digit <= 36; ++second_digit) {
@ -219,7 +219,7 @@ TEST(LlvmLibcStrToLLTest, DecodeInOtherBases) {
} }
} }
for (unsigned int base = 2; base <= 36; ++base) { for (long long base = 2; base <= 36; ++base) {
for (long long first_digit = 0; first_digit <= 36; ++first_digit) { for (long long first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit); small_string[0] = int_to_b36_char(first_digit);
for (long long second_digit = 0; second_digit <= 36; ++second_digit) { for (long long second_digit = 0; second_digit <= 36; ++second_digit) {

View File

@ -147,7 +147,7 @@ static char int_to_b36_char(int input) {
TEST(LlvmLibcStrToULTest, DecodeInOtherBases) { TEST(LlvmLibcStrToULTest, DecodeInOtherBases) {
char small_string[4] = {'\0', '\0', '\0', '\0'}; char small_string[4] = {'\0', '\0', '\0', '\0'};
for (unsigned int base = 2; base <= 36; ++base) { for (unsigned long base = 2; base <= 36; ++base) {
for (unsigned long first_digit = 0; first_digit <= 36; ++first_digit) { for (unsigned long first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit); small_string[0] = int_to_b36_char(first_digit);
if (first_digit < base) { if (first_digit < base) {
@ -163,7 +163,7 @@ TEST(LlvmLibcStrToULTest, DecodeInOtherBases) {
} }
} }
for (unsigned int base = 2; base <= 36; ++base) { for (unsigned long base = 2; base <= 36; ++base) {
for (unsigned long first_digit = 0; first_digit <= 36; ++first_digit) { for (unsigned long first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit); small_string[0] = int_to_b36_char(first_digit);
for (unsigned long second_digit = 0; second_digit <= 36; ++second_digit) { for (unsigned long second_digit = 0; second_digit <= 36; ++second_digit) {
@ -187,7 +187,7 @@ TEST(LlvmLibcStrToULTest, DecodeInOtherBases) {
} }
} }
for (unsigned int base = 2; base <= 36; ++base) { for (unsigned long base = 2; base <= 36; ++base) {
for (unsigned long first_digit = 0; first_digit <= 36; ++first_digit) { for (unsigned long first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit); small_string[0] = int_to_b36_char(first_digit);
for (unsigned long second_digit = 0; second_digit <= 36; ++second_digit) { for (unsigned long second_digit = 0; second_digit <= 36; ++second_digit) {

View File

@ -155,7 +155,7 @@ static char int_to_b36_char(int input) {
TEST(LlvmLibcStrToULLTest, DecodeInOtherBases) { TEST(LlvmLibcStrToULLTest, DecodeInOtherBases) {
char small_string[4] = {'\0', '\0', '\0', '\0'}; char small_string[4] = {'\0', '\0', '\0', '\0'};
for (unsigned int base = 2; base <= 36; ++base) { for (unsigned long long base = 2; base <= 36; ++base) {
for (unsigned long long first_digit = 0; first_digit <= 36; ++first_digit) { for (unsigned long long first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit); small_string[0] = int_to_b36_char(first_digit);
if (first_digit < base) { if (first_digit < base) {
@ -171,7 +171,7 @@ TEST(LlvmLibcStrToULLTest, DecodeInOtherBases) {
} }
} }
for (unsigned int base = 2; base <= 36; ++base) { for (unsigned long long base = 2; base <= 36; ++base) {
for (unsigned long long first_digit = 0; first_digit <= 36; ++first_digit) { for (unsigned long long first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit); small_string[0] = int_to_b36_char(first_digit);
for (unsigned long long second_digit = 0; second_digit <= 36; for (unsigned long long second_digit = 0; second_digit <= 36;
@ -196,7 +196,7 @@ TEST(LlvmLibcStrToULLTest, DecodeInOtherBases) {
} }
} }
for (unsigned int base = 2; base <= 36; ++base) { for (unsigned long long base = 2; base <= 36; ++base) {
for (unsigned long long first_digit = 0; first_digit <= 36; ++first_digit) { for (unsigned long long first_digit = 0; first_digit <= 36; ++first_digit) {
small_string[0] = int_to_b36_char(first_digit); small_string[0] = int_to_b36_char(first_digit);
for (unsigned long long second_digit = 0; second_digit <= 36; for (unsigned long long second_digit = 0; second_digit <= 36;