1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-21 06:43:04 +01:00

Fix warnings and supply template argument

This commit is contained in:
ζeh Matt
2021-12-12 23:40:58 +02:00
parent 4f0b0e8aa4
commit 59682291f0
2 changed files with 39 additions and 37 deletions

View File

@@ -14,7 +14,7 @@ using namespace OpenRCT2;
TEST(BitTest, test_index_construction)
{
BitSet<64> bits({ 0u, 2u, 4u, 6u, 8u, 10u });
BitSet<64u> bits({ 0u, 2u, 4u, 6u, 8u, 10u });
#ifdef _M_X64
static_assert(std::is_same_v<decltype(bits)::storage_block_type, uint64_t>);
#else
@@ -23,13 +23,13 @@ TEST(BitTest, test_index_construction)
constexpr auto size = sizeof(bits);
static_assert(size == 8u);
ASSERT_EQ(bits.data()[0], 0b10101010101);
ASSERT_EQ(bits.data()[0], 0b10101010101U);
ASSERT_EQ(bits.to_string(), std::string("0000000000000000000000000000000000000000000000000000010101010101"));
}
TEST(BitTest, test_basic)
{
BitSet<8> bits;
BitSet<8u> bits;
static_assert(std::is_same_v<decltype(bits)::storage_block_type, uint8_t>);
constexpr auto size = sizeof(bits);
static_assert(size == sizeof(uint8_t));
@@ -42,13 +42,13 @@ TEST(BitTest, test_basic)
ASSERT_EQ(bits[0], false);
bits[0] = bits[6];
ASSERT_EQ(bits[0], true);
ASSERT_EQ(bits.data()[0u], 0b01000001);
ASSERT_EQ(bits.data()[0u], 0b01000001U);
ASSERT_EQ(bits.to_string(), std::string("01000001"));
}
TEST(BitTest, test_flip)
{
BitSet<8> bits;
BitSet<8u> bits;
static_assert(std::is_same_v<decltype(bits)::storage_block_type, uint8_t>);
constexpr auto size = sizeof(bits);
static_assert(size == sizeof(uint8_t));
@@ -61,7 +61,7 @@ TEST(BitTest, test_flip)
TEST(BitTest, test_trim8)
{
BitSet<5> bits;
BitSet<5u> bits;
static_assert(std::is_same_v<decltype(bits)::storage_block_type, uint8_t>);
constexpr auto size = sizeof(bits);
static_assert(size == sizeof(uint8_t));
@@ -70,12 +70,12 @@ TEST(BitTest, test_trim8)
ASSERT_EQ(bits[5], false);
ASSERT_EQ(bits[6], false);
ASSERT_EQ(bits[7], false);
ASSERT_EQ(bits.data()[0u], 0b00011111);
ASSERT_EQ(bits.data()[0u], 0b00011111u);
}
TEST(BitTest, test_trim16)
{
BitSet<14> bits;
BitSet<14u> bits;
static_assert(std::is_same_v<decltype(bits)::storage_block_type, uint16_t>);
constexpr auto size = sizeof(bits);
static_assert(size == sizeof(uint16_t));
@@ -83,13 +83,13 @@ TEST(BitTest, test_trim16)
bits.flip();
ASSERT_EQ(bits[14], false);
ASSERT_EQ(bits[15], false);
ASSERT_EQ(bits.data()[0u], 0b0011111111111111);
ASSERT_EQ(bits.data()[0u], 0b0011111111111111u);
ASSERT_EQ(bits.to_string(), std::string("11111111111111"));
}
TEST(BitTest, test_big)
{
BitSet<256> bits;
BitSet<256u> bits;
constexpr auto size = sizeof(bits);
static_assert(size == 32u);
@@ -115,28 +115,28 @@ TEST(BitTest, test_big)
TEST(BitTest, test_xor5)
{
BitSet<5> bits1({ 0u, 2u, 4u });
BitSet<5> bits2({ 0u, 1u, 3u });
BitSet<5u> bits1({ 0u, 2u, 4u });
BitSet<5u> bits2({ 0u, 1u, 3u });
auto res = bits1 ^ bits2;
ASSERT_EQ(res.data()[0], 0b11110);
ASSERT_EQ(res.data()[0], 0b11110u);
ASSERT_EQ(res.to_string(), "11110");
}
TEST(BitTest, test_xor15)
{
BitSet<15> bits1({ 0u, 2u, 4u });
BitSet<15> bits2({ 0u, 1u, 3u, 14u });
BitSet<15u> bits1({ 0u, 2u, 4u });
BitSet<15u> bits2({ 0u, 1u, 3u, 14u });
auto res = bits1 ^ bits2;
ASSERT_EQ(res.data()[0], 0b0100000000011110);
ASSERT_EQ(res.data()[0], 0b0100000000011110u);
ASSERT_EQ(res.to_string(), "100000000011110");
}
TEST(BitTest, test_or5)
{
BitSet<5> bits1({ 0u, 2u, 4u });
BitSet<5> bits2({ 0u, 1u, 3u });
BitSet<5u> bits1({ 0u, 2u, 4u });
BitSet<5u> bits2({ 0u, 1u, 3u });
auto res = bits1 | bits2;
ASSERT_EQ(res.data()[0], 0b11111);
@@ -145,18 +145,18 @@ TEST(BitTest, test_or5)
TEST(BitTest, test_or15)
{
BitSet<15> bits1({ 0u, 2u, 4u });
BitSet<15> bits2({ 0u, 1u, 3u, 14u });
BitSet<15u> bits1({ 0u, 2u, 4u });
BitSet<15u> bits2({ 0u, 1u, 3u, 14u });
auto res = bits1 | bits2;
ASSERT_EQ(res.data()[0], 0b0100000000011111);
ASSERT_EQ(res.data()[0], 0b0100000000011111u);
ASSERT_EQ(res.to_string(), "100000000011111");
}
TEST(BitTest, test_and5)
{
BitSet<5> bits1({ 0u, 2u, 4u });
BitSet<5> bits2({ 0u, 1u, 3u });
BitSet<5u> bits1({ 0u, 2u, 4u });
BitSet<5u> bits2({ 0u, 1u, 3u });
auto res = bits1 & bits2;
ASSERT_EQ(res.data()[0], 0b1);
@@ -165,8 +165,8 @@ TEST(BitTest, test_and5)
TEST(BitTest, test_and15)
{
BitSet<15> bits1({ 0u, 2u, 4u });
BitSet<15> bits2({ 0u, 1u, 3u, 14u });
BitSet<15u> bits1({ 0u, 2u, 4u });
BitSet<15u> bits2({ 0u, 1u, 3u, 14u });
auto res = bits1 & bits2;
ASSERT_EQ(res.data()[0], 0b1);
@@ -175,31 +175,31 @@ TEST(BitTest, test_and15)
TEST(BitTest, test_neg5)
{
BitSet<5> bits1({ 0u, 2u, 4u });
BitSet<5u> bits1({ 0u, 2u, 4u });
auto res = ~bits1;
ASSERT_EQ(res.data()[0], 0b01010);
ASSERT_EQ(res.data()[0], 0b01010u);
ASSERT_EQ(res.to_string(), "01010");
}
TEST(BitTest, test_neg15)
{
BitSet<15> bits1({ 0u, 2u, 4u });
BitSet<15u> bits1({ 0u, 2u, 4u });
auto res = ~bits1;
ASSERT_EQ(res.data()[0], 0b111111111101010);
ASSERT_EQ(res.data()[0], 0b111111111101010u);
ASSERT_EQ(res.to_string(), "111111111101010");
}
TEST(BitTest, test_count)
{
BitSet<31> bits1({ 0u, 2u, 4u, 7u, 9u, 12u, 16u, 19u, 22u, 29u });
BitSet<31u> bits1({ 0u, 2u, 4u, 7u, 9u, 12u, 16u, 19u, 22u, 29u });
ASSERT_EQ(bits1.count(), 10u);
}
TEST(BitTest, test_iterator)
{
BitSet<31> bits1({ 0u, 2u, 4u, 7u, 9u, 12u, 16u, 19u, 22u, 29u });
BitSet<31u> bits1({ 0u, 2u, 4u, 7u, 9u, 12u, 16u, 19u, 22u, 29u });
int totalBits = 0;
for (auto v : bits1)
@@ -212,7 +212,7 @@ TEST(BitTest, test_iterator)
TEST(BitTest, test_iterator_const)
{
BitSet<31> bits1({ 0u, 2u, 4u, 7u, 9u, 12u, 16u, 19u, 22u, 29u });
BitSet<31u> bits1({ 0u, 2u, 4u, 7u, 9u, 12u, 16u, 19u, 22u, 29u });
int totalBits = 0;
auto test = [&](const auto& b) {