diff --git a/Source/UnitTests/Common/BitFieldTest.cpp b/Source/UnitTests/Common/BitFieldTest.cpp index 24ef6bd90c..3299b0402c 100644 --- a/Source/UnitTests/Common/BitFieldTest.cpp +++ b/Source/UnitTests/Common/BitFieldTest.cpp @@ -58,7 +58,7 @@ TEST(BitField, Storage) { TestUnion object; - EXPECT_EQ((void*)&object.hex, (void*)&object.regular_field_unsigned); + EXPECT_EQ(static_cast(&object.hex), static_cast(&object.regular_field_unsigned)); EXPECT_EQ(sizeof(TestUnion), sizeof(object.hex)); EXPECT_EQ(sizeof(TestUnion), sizeof(object.full_u64)); EXPECT_EQ(sizeof(TestUnion), sizeof(object.full_s64)); @@ -93,14 +93,14 @@ TEST(BitField, Read) object.hex = val; // Make sure reading/casting does not behave completely idiotic - EXPECT_EQ(object.full_u64, (u64)object.full_u64); - EXPECT_EQ(object.full_s64, (s64)object.full_s64); - EXPECT_EQ(object.regular_field_unsigned, (u64)object.regular_field_unsigned); - EXPECT_EQ(object.regular_field_unsigned2, (u64)object.regular_field_unsigned2); - EXPECT_EQ(object.regular_field_signed, (s64)object.regular_field_signed); - EXPECT_EQ(object.at_dword_boundary, (s64)object.at_dword_boundary); - EXPECT_EQ(object.signed_1bit, (s64)object.signed_1bit); - EXPECT_EQ(object.flag, (bool)object.flag); + EXPECT_EQ(object.full_u64, static_cast(object.full_u64)); + EXPECT_EQ(object.full_s64, static_cast(object.full_s64)); + EXPECT_EQ(object.regular_field_unsigned, static_cast(object.regular_field_unsigned)); + EXPECT_EQ(object.regular_field_unsigned2, static_cast(object.regular_field_unsigned2)); + EXPECT_EQ(object.regular_field_signed, static_cast(object.regular_field_signed)); + EXPECT_EQ(object.at_dword_boundary, static_cast(object.at_dword_boundary)); + EXPECT_EQ(object.signed_1bit, static_cast(object.signed_1bit)); + EXPECT_EQ(object.flag, static_cast(object.flag)); EXPECT_EQ(object.enum_1, static_cast(object.enum_1)); EXPECT_EQ(object.enum_2, static_cast(object.enum_2)); @@ -109,10 +109,10 @@ TEST(BitField, Read) EXPECT_EQ(*(s64*)&val, object.full_s64); EXPECT_EQ((val >> 9) & 0x7, object.regular_field_unsigned); EXPECT_EQ((val >> 9) & 0x7, object.regular_field_unsigned2); - EXPECT_EQ(((s64)(object.hex << 52)) >> 61, object.regular_field_signed); - EXPECT_EQ(((s64)(object.hex << 30)) >> 60, object.at_dword_boundary); + EXPECT_EQ(static_cast(object.hex << 52) >> 61, object.regular_field_signed); + EXPECT_EQ(static_cast(object.hex << 30) >> 60, object.at_dword_boundary); EXPECT_EQ(((object.hex >> 15) & 1) ? -1 : 0, object.signed_1bit); - EXPECT_EQ((bool)object.flag, ((object.hex >> 63) & 1)); + EXPECT_EQ(static_cast(object.flag), ((object.hex >> 63) & 1)); EXPECT_EQ(static_cast((object.hex >> 16) & 3), object.enum_1); EXPECT_EQ(static_cast((object.hex >> 48) & 3), object.enum_2); } @@ -128,20 +128,20 @@ TEST(BitField, Assignment) object.full_u64 = val; EXPECT_EQ(val, object.full_u64); - object.full_s64 = (s64)val; + object.full_s64 = static_cast(val); EXPECT_EQ(val, object.full_u64); object.regular_field_unsigned = val; EXPECT_EQ(val & 0x7, object.regular_field_unsigned); object.at_dword_boundary = val; - EXPECT_EQ(((s64)(val << 60)) >> 60, object.at_dword_boundary); + EXPECT_EQ(static_cast(val << 60) >> 60, object.at_dword_boundary); object.signed_1bit = val; EXPECT_EQ((val & 1) ? -1 : 0, object.signed_1bit); object.regular_field_signed = val; - EXPECT_EQ(((s64)(object.hex << 61)) >> 61, object.regular_field_signed); + EXPECT_EQ(static_cast(object.hex << 61) >> 61, object.regular_field_signed); // Assignment from other BitField object.at_dword_boundary = object.regular_field_signed; @@ -175,20 +175,20 @@ TEST(BitField, Alignment) object.full_u64 = val; EXPECT_EQ(val, object.full_u64); - object.full_s64 = (s64)val; + object.full_s64 = static_cast(val); EXPECT_EQ(val, object.full_u64); object.regular_field_unsigned = val; EXPECT_EQ(val & 0x7, object.regular_field_unsigned); object.at_dword_boundary = val; - EXPECT_EQ(((s64)(val << 60)) >> 60, object.at_dword_boundary); + EXPECT_EQ(static_cast(val << 60) >> 60, object.at_dword_boundary); object.signed_1bit = val; EXPECT_EQ((val & 1) ? -1 : 0, object.signed_1bit); object.regular_field_signed = val; - EXPECT_EQ(((s64)(object.hex << 61)) >> 61, object.regular_field_signed); + EXPECT_EQ(static_cast(object.hex << 61) >> 61, object.regular_field_signed); // Assignment from other BitField object.at_dword_boundary = object.regular_field_signed; diff --git a/Source/UnitTests/Common/BitSetTest.cpp b/Source/UnitTests/Common/BitSetTest.cpp index 397f9fecbe..066d8cc022 100644 --- a/Source/UnitTests/Common/BitSetTest.cpp +++ b/Source/UnitTests/Common/BitSetTest.cpp @@ -27,7 +27,7 @@ TEST(BitSet, BitGetSet) bs[3] = bs[8] = bs[11] = true; EXPECT_TRUE(bs[3]); EXPECT_FALSE(bs[4]); - EXPECT_EQ((u32)((1 << 3) | (1 << 8) | (1 << 11)), bs.m_val); + EXPECT_EQ(static_cast((1 << 3) | (1 << 8) | (1 << 11)), bs.m_val); } TEST(BitSet, Count) diff --git a/Source/UnitTests/Common/BitUtilsTest.cpp b/Source/UnitTests/Common/BitUtilsTest.cpp index 8244941cf8..96ef5a5e9c 100644 --- a/Source/UnitTests/Common/BitUtilsTest.cpp +++ b/Source/UnitTests/Common/BitUtilsTest.cpp @@ -68,23 +68,23 @@ TEST(BitUtils, IsValidLowMask) EXPECT_FALSE(Common::IsValidLowMask(0b10000u)); EXPECT_FALSE(Common::IsValidLowMask(0b101111u)); - EXPECT_TRUE(Common::IsValidLowMask((u8)~0b0)); - EXPECT_FALSE(Common::IsValidLowMask((u8)(~0b0 - 1))); - EXPECT_FALSE(Common::IsValidLowMask((u8) ~(0b10000))); - EXPECT_FALSE(Common::IsValidLowMask((u8)(~((u8)(~0b0) >> 1) | 0b1111))); + EXPECT_TRUE(Common::IsValidLowMask(static_cast(~0b0))); + EXPECT_FALSE(Common::IsValidLowMask(static_cast(~0b0 - 1))); + EXPECT_FALSE(Common::IsValidLowMask(static_cast(~(0b10000)))); + EXPECT_FALSE(Common::IsValidLowMask((u8)(~(static_cast(~0b0) >> 1) | 0b1111))); - EXPECT_TRUE(Common::IsValidLowMask((u16)~0b0)); - EXPECT_FALSE(Common::IsValidLowMask((u16)(~0b0 - 1))); - EXPECT_FALSE(Common::IsValidLowMask((u16) ~(0b10000))); - EXPECT_FALSE(Common::IsValidLowMask((u16)(~((u16)(~0b0) >> 1) | 0b1111))); + EXPECT_TRUE(Common::IsValidLowMask(static_cast(~0b0))); + EXPECT_FALSE(Common::IsValidLowMask(static_cast(~0b0 - 1))); + EXPECT_FALSE(Common::IsValidLowMask(static_cast(~(0b10000)))); + EXPECT_FALSE(Common::IsValidLowMask((u16)(~(static_cast(~0b0) >> 1) | 0b1111))); - EXPECT_TRUE(Common::IsValidLowMask((u32)~0b0)); - EXPECT_FALSE(Common::IsValidLowMask((u32)(~0b0 - 1))); - EXPECT_FALSE(Common::IsValidLowMask((u32) ~(0b10000))); - EXPECT_FALSE(Common::IsValidLowMask((u32)(~((u32)(~0b0) >> 1) | 0b1111))); + EXPECT_TRUE(Common::IsValidLowMask(static_cast(~0b0))); + EXPECT_FALSE(Common::IsValidLowMask(static_cast(~0b0 - 1))); + EXPECT_FALSE(Common::IsValidLowMask(static_cast(~(0b10000)))); + EXPECT_FALSE(Common::IsValidLowMask((u32)(~(static_cast(~0b0) >> 1) | 0b1111))); - EXPECT_TRUE(Common::IsValidLowMask((u64)~0b0)); - EXPECT_FALSE(Common::IsValidLowMask((u64)(~0b0 - 1))); - EXPECT_FALSE(Common::IsValidLowMask((u64) ~(0b10000))); - EXPECT_FALSE(Common::IsValidLowMask((u64)(~((u64)(~0b0) >> 1) | 0b1111))); + EXPECT_TRUE(Common::IsValidLowMask(static_cast(~0b0))); + EXPECT_FALSE(Common::IsValidLowMask(static_cast(~0b0 - 1))); + EXPECT_FALSE(Common::IsValidLowMask(static_cast(~(0b10000)))); + EXPECT_FALSE(Common::IsValidLowMask((u64)(~(static_cast(~0b0) >> 1) | 0b1111))); } diff --git a/Source/UnitTests/Common/MathUtilTest.cpp b/Source/UnitTests/Common/MathUtilTest.cpp index 7758bb5d7f..59baa36eda 100644 --- a/Source/UnitTests/Common/MathUtilTest.cpp +++ b/Source/UnitTests/Common/MathUtilTest.cpp @@ -64,8 +64,8 @@ TEST(MathUtil, SaturatingCast) EXPECT_EQ(std::numeric_limits::min(), MathUtil::SaturatingCast(-std::numeric_limits::infinity())); // 16777217 = 2^24 + 1 is the first integer that cannot be represented correctly with a f32. - EXPECT_EQ(16777216, MathUtil::SaturatingCast(float(16777216))); - EXPECT_EQ(16777216, MathUtil::SaturatingCast(float(16777217))); + EXPECT_EQ(16777216, MathUtil::SaturatingCast(static_cast(16777216))); + EXPECT_EQ(16777216, MathUtil::SaturatingCast(static_cast(16777217))); } TEST(MathUtil, RectangleEquality) diff --git a/Source/UnitTests/Core/IOS/ES/FormatsTest.cpp b/Source/UnitTests/Core/IOS/ES/FormatsTest.cpp index c2082ffbc8..a98fa60bf3 100644 --- a/Source/UnitTests/Core/IOS/ES/FormatsTest.cpp +++ b/Source/UnitTests/Core/IOS/ES/FormatsTest.cpp @@ -141,7 +141,7 @@ TEST_F(GameTMDReaderTest, ContentInfo) EXPECT_FALSE(m_tmd.GetContent(1, &content)) << "Content with index 1 should not exist"; const std::vector contents = m_tmd.GetContents(); - ASSERT_EQ(contents.size(), size_t(1)); + ASSERT_EQ(contents.size(), static_cast(1)); check_is_expected_content(contents.at(0)); } @@ -205,7 +205,7 @@ TEST_F(IOSTMDReaderTest, ContentInfo) }; const std::vector contents = m_tmd.GetContents(); - ASSERT_EQ(contents.size(), size_t(23)); + ASSERT_EQ(contents.size(), static_cast(23)); IOS::ES::Content content; diff --git a/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp b/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp index 675be35355..b024ddf93a 100644 --- a/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp +++ b/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp @@ -65,7 +65,7 @@ protected: { m_loader = VertexLoaderBase::CreateVertexLoader(m_vtx_desc, m_vtx_attr); ASSERT_EQ(input_size, m_loader->m_vertex_size); - ASSERT_EQ((int)output_size, m_loader->m_native_vtx_decl.stride); + ASSERT_EQ(static_cast(output_size), m_loader->m_native_vtx_decl.stride); } template @@ -166,7 +166,7 @@ TEST_P(VertexLoaderParamTest, PositionAll) ASSERT_EQ(0u, values.size() % 2); ASSERT_EQ(0u, values.size() % 3); - int count = (int)values.size() / elem_count; + int count = static_cast(values.size()) / elem_count; size_t input_size = elem_count * elem_size; if (IsIndexed(addr)) { @@ -975,7 +975,7 @@ TEST_P(VertexLoaderSkippedTexCoordsTest, SkippedTextures) for (size_t i = 0; i < NUM_COMPONENTS_TO_TEST; i++) { if (enable_matrix[i]) - Input(u8(20 + i)); + Input(static_cast(20 + i)); } Input(1); // Position for (size_t i = 0; i < NUM_COMPONENTS_TO_TEST; i++) @@ -987,7 +987,7 @@ TEST_P(VertexLoaderSkippedTexCoordsTest, SkippedTextures) for (size_t i = 0; i < NUM_COMPONENTS_TO_TEST; i++) { if (enable_matrix[i]) - Input(u8(10 + i)); + Input(static_cast(10 + i)); } Input(0); // Position for (size_t i = 0; i < NUM_COMPONENTS_TO_TEST; i++)