Skip to content

Commit

Permalink
Merge pull request #5154 from ligfx/bitutilstestsignedness
Browse files Browse the repository at this point in the history
BitUtilsTest: compare ints of the same signedness (fixes warnings)
  • Loading branch information
Parlane committed Mar 25, 2017
2 parents c5cc781 + 9234ed8 commit d8fa465
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions Source/UnitTests/Common/BitUtilsTest.cpp
Expand Up @@ -9,15 +9,15 @@

TEST(BitUtils, BitSize)
{
EXPECT_EQ(Common::BitSize<s8>(), 8);
EXPECT_EQ(Common::BitSize<s16>(), 16);
EXPECT_EQ(Common::BitSize<s32>(), 32);
EXPECT_EQ(Common::BitSize<s64>(), 64);

EXPECT_EQ(Common::BitSize<u8>(), 8);
EXPECT_EQ(Common::BitSize<u16>(), 16);
EXPECT_EQ(Common::BitSize<u32>(), 32);
EXPECT_EQ(Common::BitSize<u64>(), 64);
EXPECT_EQ(Common::BitSize<s8>(), 8u);
EXPECT_EQ(Common::BitSize<s16>(), 16u);
EXPECT_EQ(Common::BitSize<s32>(), 32u);
EXPECT_EQ(Common::BitSize<s64>(), 64u);

EXPECT_EQ(Common::BitSize<u8>(), 8u);
EXPECT_EQ(Common::BitSize<u16>(), 16u);
EXPECT_EQ(Common::BitSize<u32>(), 32u);
EXPECT_EQ(Common::BitSize<u64>(), 64u);
}

TEST(BitUtils, ExtractBit)
Expand All @@ -41,14 +41,14 @@ TEST(BitUtils, ExtractBits)
// mangling the template function usages.

constexpr s32 two_hundred_four_signed = 0b0011001100;
EXPECT_EQ((Common::ExtractBits<2, 3>(two_hundred_four_signed)), 3);
EXPECT_EQ((Common::ExtractBits<2, 7>(two_hundred_four_signed)), 51);
EXPECT_EQ((Common::ExtractBits<3, 6>(two_hundred_four_signed)), 9);
EXPECT_EQ((Common::ExtractBits<2, 3>(two_hundred_four_signed)), 3u);
EXPECT_EQ((Common::ExtractBits<2, 7>(two_hundred_four_signed)), 51u);
EXPECT_EQ((Common::ExtractBits<3, 6>(two_hundred_four_signed)), 9u);

constexpr u32 two_hundred_four_unsigned = 0b0011001100;
EXPECT_EQ((Common::ExtractBits<2, 3>(two_hundred_four_unsigned)), 3);
EXPECT_EQ((Common::ExtractBits<2, 7>(two_hundred_four_unsigned)), 51);
EXPECT_EQ((Common::ExtractBits<3, 6>(two_hundred_four_unsigned)), 9);
EXPECT_EQ((Common::ExtractBits<2, 3>(two_hundred_four_unsigned)), 3u);
EXPECT_EQ((Common::ExtractBits<2, 7>(two_hundred_four_unsigned)), 51u);
EXPECT_EQ((Common::ExtractBits<3, 6>(two_hundred_four_unsigned)), 9u);

// Ensure bit extraction remains sign-independent even when signed types are used.
constexpr s32 negative_one = -1;
Expand Down

0 comments on commit d8fa465

Please sign in to comment.