Improve coding style (after running clang-tidy)

This commit is contained in:
Martchus 2018-08-12 22:09:22 +02:00
parent d0bf2fb390
commit 61f7ce90e1
2 changed files with 9 additions and 9 deletions

View File

@ -76,7 +76,7 @@ template <typename intType> intType BitReader::readBits(byte bitCount)
m_bitsAvail = 8; m_bitsAvail = 8;
} }
readAtOnce = std::min(bitCount, m_bitsAvail); readAtOnce = std::min(bitCount, m_bitsAvail);
val = (val << readAtOnce) | (((*m_buffer) >> (m_bitsAvail -= readAtOnce)) & (0xFF >> (0x08 - readAtOnce))); val = static_cast<intType>((val << readAtOnce) | (((*m_buffer) >> (m_bitsAvail -= readAtOnce)) & (0xFF >> (0x08 - readAtOnce))));
} }
return val; return val;
} }

View File

@ -257,15 +257,15 @@ void IoTests::testBitReader()
BitReader reader(reinterpret_cast<const char *>(testData), sizeof(testData)); BitReader reader(reinterpret_cast<const char *>(testData), sizeof(testData));
CPPUNIT_ASSERT(reader.readBit() == 1); CPPUNIT_ASSERT(reader.readBit() == 1);
reader.skipBits(6); reader.skipBits(6);
CPPUNIT_ASSERT(reader.showBits<byte>(2) == 3); CPPUNIT_ASSERT_EQUAL(static_cast<byte>(3), reader.showBits<byte>(2));
CPPUNIT_ASSERT(reader.readBits<byte>(2) == 3); CPPUNIT_ASSERT_EQUAL(static_cast<byte>(3), reader.readBits<byte>(2));
CPPUNIT_ASSERT(reader.readBits<uint32>(32) == (0x103C4428 << 1)); CPPUNIT_ASSERT_EQUAL(static_cast<uint32>(0x103C4428 << 1), reader.readBits<uint32>(32));
reader.align(); reader.align();
CPPUNIT_ASSERT(reader.readBits<byte>(8) == 0x44); CPPUNIT_ASSERT_EQUAL(static_cast<byte>(0x44), reader.readBits<byte>(8));
CPPUNIT_ASSERT(reader.readUnsignedExpGolombCodedBits<byte>() == 7); CPPUNIT_ASSERT_EQUAL(static_cast<byte>(7), reader.readUnsignedExpGolombCodedBits<byte>());
CPPUNIT_ASSERT(reader.readSignedExpGolombCodedBits<sbyte>() == 4); CPPUNIT_ASSERT_EQUAL(static_cast<sbyte>(4), reader.readSignedExpGolombCodedBits<sbyte>());
CPPUNIT_ASSERT(reader.readBit() == 0); CPPUNIT_ASSERT_EQUAL(static_cast<byte>(0), reader.readBit());
CPPUNIT_ASSERT(reader.readBit() == 0); CPPUNIT_ASSERT_EQUAL(static_cast<byte>(0), reader.readBit());
reader.skipBits(8 + 4); reader.skipBits(8 + 4);
CPPUNIT_ASSERT_EQUAL(4_st, reader.bitsAvailable()); CPPUNIT_ASSERT_EQUAL(4_st, reader.bitsAvailable());
CPPUNIT_ASSERT_EQUAL(static_cast<byte>(0xA), reader.readBits<byte>(4)); CPPUNIT_ASSERT_EQUAL(static_cast<byte>(0xA), reader.readBits<byte>(4));