Improve coding style (after running clang-tidy)

sendfile
Martchus 4 years ago
parent d0bf2fb390
commit 61f7ce90e1
  1. 2
      io/bitreader.h
  2. 16
      tests/iotests.cpp

@ -76,7 +76,7 @@ template <typename intType> intType BitReader::readBits(byte bitCount)
m_bitsAvail = 8;
}
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;
}

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

Loading…
Cancel
Save