[Support][MathExtras] Fix literal type issues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182679 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael J. Spencer 2013-05-24 22:19:05 +00:00
parent c93cdefa30
commit 54c7482388

View File

@ -19,19 +19,19 @@ TEST(MathExtras, countTrailingZeros) {
uint16_t Z16 = 0;
uint32_t Z32 = 0;
uint64_t Z64 = 0;
EXPECT_EQ(8, countTrailingZeros(Z8));
EXPECT_EQ(16, countTrailingZeros(Z16));
EXPECT_EQ(32, countTrailingZeros(Z32));
EXPECT_EQ(64, countTrailingZeros(Z64));
EXPECT_EQ(8u, countTrailingZeros(Z8));
EXPECT_EQ(16u, countTrailingZeros(Z16));
EXPECT_EQ(32u, countTrailingZeros(Z32));
EXPECT_EQ(64u, countTrailingZeros(Z64));
uint8_t NZ8 = 42;
uint16_t NZ16 = 42;
uint32_t NZ32 = 42;
uint64_t NZ64 = 42;
EXPECT_EQ(1, countTrailingZeros(NZ8));
EXPECT_EQ(1, countTrailingZeros(NZ16));
EXPECT_EQ(1, countTrailingZeros(NZ32));
EXPECT_EQ(1, countTrailingZeros(NZ64));
EXPECT_EQ(1u, countTrailingZeros(NZ8));
EXPECT_EQ(1u, countTrailingZeros(NZ16));
EXPECT_EQ(1u, countTrailingZeros(NZ32));
EXPECT_EQ(1u, countTrailingZeros(NZ64));
}
TEST(MathExtras, countLeadingZeros) {
@ -39,19 +39,19 @@ TEST(MathExtras, countLeadingZeros) {
uint16_t Z16 = 0;
uint32_t Z32 = 0;
uint64_t Z64 = 0;
EXPECT_EQ(8, countLeadingZeros(Z8));
EXPECT_EQ(16, countLeadingZeros(Z16));
EXPECT_EQ(32, countLeadingZeros(Z32));
EXPECT_EQ(64, countLeadingZeros(Z64));
EXPECT_EQ(8u, countLeadingZeros(Z8));
EXPECT_EQ(16u, countLeadingZeros(Z16));
EXPECT_EQ(32u, countLeadingZeros(Z32));
EXPECT_EQ(64u, countLeadingZeros(Z64));
uint8_t NZ8 = 42;
uint16_t NZ16 = 42;
uint32_t NZ32 = 42;
uint64_t NZ64 = 42;
EXPECT_EQ(2, countLeadingZeros(NZ8));
EXPECT_EQ(10, countLeadingZeros(NZ16));
EXPECT_EQ(26, countLeadingZeros(NZ32));
EXPECT_EQ(58, countLeadingZeros(NZ64));
EXPECT_EQ(2u, countLeadingZeros(NZ8));
EXPECT_EQ(10u, countLeadingZeros(NZ16));
EXPECT_EQ(26u, countLeadingZeros(NZ32));
EXPECT_EQ(58u, countLeadingZeros(NZ64));
}
TEST(MathExtras, findFirstSet) {
@ -59,19 +59,19 @@ TEST(MathExtras, findFirstSet) {
uint16_t Z16 = 0;
uint32_t Z32 = 0;
uint64_t Z64 = 0;
EXPECT_EQ(0xFF, findFirstSet(Z8));
EXPECT_EQ(0xFFFF, findFirstSet(Z16));
EXPECT_EQ(0xFFFFFFFF, findFirstSet(Z32));
EXPECT_EQ(0xFFFFFFFFFFFFFFFF, findFirstSet(Z64));
EXPECT_EQ(0xFFULL, findFirstSet(Z8));
EXPECT_EQ(0xFFFFULL, findFirstSet(Z16));
EXPECT_EQ(0xFFFFFFFFULL, findFirstSet(Z32));
EXPECT_EQ(0xFFFFFFFFFFFFFFFFULL, findFirstSet(Z64));
uint8_t NZ8 = 42;
uint16_t NZ16 = 42;
uint32_t NZ32 = 42;
uint64_t NZ64 = 42;
EXPECT_EQ(1, findFirstSet(NZ8));
EXPECT_EQ(1, findFirstSet(NZ16));
EXPECT_EQ(1, findFirstSet(NZ32));
EXPECT_EQ(1, findFirstSet(NZ64));
EXPECT_EQ(1u, findFirstSet(NZ8));
EXPECT_EQ(1u, findFirstSet(NZ16));
EXPECT_EQ(1u, findFirstSet(NZ32));
EXPECT_EQ(1u, findFirstSet(NZ64));
}
TEST(MathExtras, findLastSet) {
@ -79,19 +79,19 @@ TEST(MathExtras, findLastSet) {
uint16_t Z16 = 0;
uint32_t Z32 = 0;
uint64_t Z64 = 0;
EXPECT_EQ(0xFF, findLastSet(Z8));
EXPECT_EQ(0xFFFF, findLastSet(Z16));
EXPECT_EQ(0xFFFFFFFF, findLastSet(Z32));
EXPECT_EQ(0xFFFFFFFFFFFFFFFF, findLastSet(Z64));
EXPECT_EQ(0xFFULL, findLastSet(Z8));
EXPECT_EQ(0xFFFFULL, findLastSet(Z16));
EXPECT_EQ(0xFFFFFFFFULL, findLastSet(Z32));
EXPECT_EQ(0xFFFFFFFFFFFFFFFFULL, findLastSet(Z64));
uint8_t NZ8 = 42;
uint16_t NZ16 = 42;
uint32_t NZ32 = 42;
uint64_t NZ64 = 42;
EXPECT_EQ(5, findLastSet(NZ8));
EXPECT_EQ(5, findLastSet(NZ16));
EXPECT_EQ(5, findLastSet(NZ32));
EXPECT_EQ(5, findLastSet(NZ64));
EXPECT_EQ(5u, findLastSet(NZ8));
EXPECT_EQ(5u, findLastSet(NZ16));
EXPECT_EQ(5u, findLastSet(NZ32));
EXPECT_EQ(5u, findLastSet(NZ64));
}
TEST(MathExtras, reverseBits) {
@ -99,10 +99,10 @@ TEST(MathExtras, reverseBits) {
uint16_t NZ16 = 42;
uint32_t NZ32 = 42;
uint64_t NZ64 = 42;
EXPECT_EQ(0x54, reverseBits(NZ8));
EXPECT_EQ(0x5400, reverseBits(NZ16));
EXPECT_EQ(0x54000000, reverseBits(NZ32));
EXPECT_EQ(0x5400000000000000, reverseBits(NZ64));
EXPECT_EQ(0x54ULL, reverseBits(NZ8));
EXPECT_EQ(0x5400ULL, reverseBits(NZ16));
EXPECT_EQ(0x54000000ULL, reverseBits(NZ32));
EXPECT_EQ(0x5400000000000000ULL, reverseBits(NZ64));
}
TEST(MathExtras, isPowerOf2_32) {