stuff-from-scratch/test/core/TestBitStream.cpp
2022-11-23 15:41:33 +00:00

30 lines
828 B
C++

#include "ByteUtils.h"
#include "BufferBitStream.h"
#include <iostream>
int main()
{
std::vector<std::string> bytes{"11100101", "00110101", "00010001"};
BufferBitStream stream;
for(const auto& byte : bytes)
{
stream.writeByte(ByteUtils::getFromString(byte));
}
unsigned char buffer{0} ;
auto valid = stream.readNextNBits(3, buffer);
std::cout << "Slice0 is " << ByteUtils::toString(buffer) << std::endl;
valid = stream.readNextNBits(3, buffer);
std::cout << "Slice1 is " << ByteUtils::toString(buffer) << std::endl;
valid = stream.readNextNBits(5, buffer);
std::cout << "Slice2 is " << ByteUtils::toString(buffer) << std::endl;
valid = stream.readNextNBits(7, buffer);
std::cout << "Slice3 is " << ByteUtils::toString(buffer) << std::endl;
return 0;
}