From 9234ed82daea71f5702e3bf66d4564eea50e19c6 Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Fri, 24 Mar 2017 17:08:19 -0700 Subject: [PATCH] BitUtilsTest: compare ints of the same signedness (fixes warnings) Fixes warnings like: ``` dolphin/Source/UnitTests/Common/BitUtilsTest.cpp:5: ../Externals/gtest/googletest/include/gtest/gtest.h:1392:11: warning: comparison of integers of different signs: 'const unsigned long' and 'const int' [-Wsign-compare] if (lhs == rhs) { ~~~ ^ ~~~ ../Externals/gtest/googletest/include/gtest/gtest.h:1421:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ' requested here return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); ^ dolphin/Source/UnitTests/Common/BitUtilsTest.cpp:12:3: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare' requested here EXPECT_EQ(Common::BitSize(), 8); ^ ../Externals/gtest/googletest/include/gtest/gtest.h:1924:63: note: expanded from macro 'EXPECT_EQ' EqHelper::Compare, \ ``` --- Source/UnitTests/Common/BitUtilsTest.cpp | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Source/UnitTests/Common/BitUtilsTest.cpp b/Source/UnitTests/Common/BitUtilsTest.cpp index f607f0da2fad..987868e6e48c 100644 --- a/Source/UnitTests/Common/BitUtilsTest.cpp +++ b/Source/UnitTests/Common/BitUtilsTest.cpp @@ -9,15 +9,15 @@ TEST(BitUtils, BitSize) { - EXPECT_EQ(Common::BitSize(), 8); - EXPECT_EQ(Common::BitSize(), 16); - EXPECT_EQ(Common::BitSize(), 32); - EXPECT_EQ(Common::BitSize(), 64); - - EXPECT_EQ(Common::BitSize(), 8); - EXPECT_EQ(Common::BitSize(), 16); - EXPECT_EQ(Common::BitSize(), 32); - EXPECT_EQ(Common::BitSize(), 64); + EXPECT_EQ(Common::BitSize(), 8u); + EXPECT_EQ(Common::BitSize(), 16u); + EXPECT_EQ(Common::BitSize(), 32u); + EXPECT_EQ(Common::BitSize(), 64u); + + EXPECT_EQ(Common::BitSize(), 8u); + EXPECT_EQ(Common::BitSize(), 16u); + EXPECT_EQ(Common::BitSize(), 32u); + EXPECT_EQ(Common::BitSize(), 64u); } TEST(BitUtils, ExtractBit) @@ -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;