BytesRead = Buf.size() - NextChar;
CurWord = 0;
for (unsigned B = 0; B != BytesRead; ++B)
- CurWord |= NextCharPtr[B] << (B * 8);
+ CurWord |= uint64_t(NextCharPtr[B]) << (B * 8);
}
NextChar += BytesRead;
BitsInCurWord = BytesRead * 8;
}
}
+TEST(BitstreamReaderTest, shortRead) {
+ uint8_t Bytes[] = {8, 7, 6, 5, 4, 3, 2, 1};
+ for (unsigned I = 1; I != 8; ++I) {
+ BitstreamReader Reader(ArrayRef<uint8_t>(Bytes, I));
+ SimpleBitstreamCursor Cursor(Reader);
+ EXPECT_EQ(8ull, Cursor.Read(8));
+ }
+}
+
} // end anonymous namespace