Core lib building
This commit is contained in:
parent
3ed195d7dd
commit
94fcc42aed
73 changed files with 625 additions and 661 deletions
|
@ -3,7 +3,7 @@ include(TestTargets)
|
|||
unit_tests(
|
||||
MODULE_NAME core
|
||||
FILES
|
||||
TestByteUtils.cpp
|
||||
TestBits.cpp
|
||||
TestBitStream.cpp
|
||||
TestDataStructures.cpp
|
||||
TestTomlReader.cpp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "ByteUtils.h"
|
||||
#include "Bits.h"
|
||||
#include "BufferBitStream.h"
|
||||
|
||||
#include "TestFramework.h"
|
||||
|
@ -16,27 +16,27 @@ TEST_CASE(TestReadBitStream, "core")
|
|||
BufferBitStream stream;
|
||||
for(const auto& byte : bytes)
|
||||
{
|
||||
stream.writeByte(ByteUtils::getFromString(byte));
|
||||
stream.writeByte(Bits::getFromString(byte));
|
||||
}
|
||||
|
||||
unsigned char buffer{0} ;
|
||||
auto valid = stream.readNextNBits(1, buffer);
|
||||
//std::cout << "Slice0 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
//std::cout << "Slice0 is " << Bits::toString(buffer) << std::endl;
|
||||
|
||||
valid = stream.readNextNBits(2, buffer);
|
||||
//std::cout << "Slice1 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
//std::cout << "Slice1 is " << Bits::toString(buffer) << std::endl;
|
||||
|
||||
valid = stream.readNextNBits(5, buffer);
|
||||
//std::cout << "Slice2 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
//std::cout << "Slice2 is " << Bits::toString(buffer) << std::endl;
|
||||
|
||||
valid = stream.readNextNBits(5, buffer);
|
||||
//std::cout << "Slice3 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
//std::cout << "Slice3 is " << Bits::toString(buffer) << std::endl;
|
||||
|
||||
valid = stream.readNextNBits(4, buffer);
|
||||
//std::cout << "Slice3 is " << ByteUtils::toString(buffer) << " and int " << static_cast<int>(buffer) << std::endl;
|
||||
//std::cout << "Slice3 is " << Bits::toString(buffer) << " and int " << static_cast<int>(buffer) << std::endl;
|
||||
|
||||
valid = stream.readNextNBits(3, buffer);
|
||||
//std::cout << "Slice3 is " << ByteUtils::toString(buffer) << std::endl;
|
||||
//std::cout << "Slice3 is " << Bits::toString(buffer) << std::endl;
|
||||
REQUIRE(valid);
|
||||
}
|
||||
|
||||
|
@ -44,30 +44,30 @@ TEST_CASE(TestWritingBitStream, "core")
|
|||
{
|
||||
BufferBitStream stream;
|
||||
|
||||
stream.writeByte(ByteUtils::getFromString("01100000"));
|
||||
stream.writeByte(Bits::getFromString("01100000"));
|
||||
|
||||
auto bits0 = ByteUtils::getFromString("00000111");
|
||||
auto bits0 = Bits::getFromString("00000111");
|
||||
stream.writeNBits(bits0, 3);
|
||||
|
||||
stream.writeByte(ByteUtils::getFromString("11110000"));
|
||||
stream.writeByte(Bits::getFromString("11110000"));
|
||||
|
||||
auto bits1 = ByteUtils::getFromString("01001101");
|
||||
auto bits1 = Bits::getFromString("01001101");
|
||||
stream.writeNBits(bits1, 7);
|
||||
|
||||
stream.writeByte(ByteUtils::getFromString("11110000"));
|
||||
stream.writeByte(Bits::getFromString("11110000"));
|
||||
|
||||
auto bits2 = ByteUtils::getFromString("00000001");
|
||||
auto bits2 = Bits::getFromString("00000001");
|
||||
stream.writeNBits(bits2, 1);
|
||||
|
||||
stream.flushRemainingBits();
|
||||
|
||||
stream.resetOffsets();
|
||||
|
||||
auto byte0 = ByteUtils::toString(*stream.readNextByte());
|
||||
auto byte1 = ByteUtils::toString(*stream.readNextByte());
|
||||
auto byte2 = ByteUtils::toString(*stream.readNextByte());
|
||||
auto byte3 = ByteUtils::toString(*stream.readNextByte());
|
||||
auto byte4 = ByteUtils::toString(*stream.readNextByte());
|
||||
auto byte0 = Bits::toString(*stream.readNextByte());
|
||||
auto byte1 = Bits::toString(*stream.readNextByte());
|
||||
auto byte2 = Bits::toString(*stream.readNextByte());
|
||||
auto byte3 = Bits::toString(*stream.readNextByte());
|
||||
auto byte4 = Bits::toString(*stream.readNextByte());
|
||||
|
||||
//std::cout << "Got bytes 0 " << byte0 << std::endl;
|
||||
//std::cout << "Got bytes 1 " << byte1 << std::endl;
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
#include "ByteUtils.h"
|
||||
#include "Bits.h"
|
||||
|
||||
#include "TestFramework.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
TEST_CASE(TestReadByteUtils, "core")
|
||||
TEST_CASE(TestReadBits, "core")
|
||||
{
|
||||
auto byte = ByteUtils::getFromString("00110101");
|
||||
auto byte = Bits::getFromString("00110101");
|
||||
//std::cout << "Value is " << static_cast<unsigned>(byte) << std::endl;
|
||||
|
||||
auto string_rep = ByteUtils::toString(byte);
|
||||
auto string_rep = Bits::toString(byte);
|
||||
//std::cout << "String rep is " << string_rep << std::endl;
|
||||
|
||||
auto slice = ByteUtils::getMBitsAtN(byte, 3, 3);
|
||||
//std::cout << "Slice is " << ByteUtils::toString(slice) << std::endl;
|
||||
auto slice = Bits::getMBitsAtN(byte, 3, 3);
|
||||
//std::cout << "Slice is " << Bits::toString(slice) << std::endl;
|
||||
(void) slice;
|
||||
|
||||
uint32_t input {12345678};
|
||||
auto byte0 = ByteUtils::getByteN(input, 0);
|
||||
auto byte1 = ByteUtils::getByteN(input, 1);
|
||||
auto byte2 = ByteUtils::getByteN(input, 2);
|
||||
auto byte3 = ByteUtils::getByteN(input, 3);
|
||||
auto byte0 = Bits::getByteN(input, 0);
|
||||
auto byte1 = Bits::getByteN(input, 1);
|
||||
auto byte2 = Bits::getByteN(input, 2);
|
||||
auto byte3 = Bits::getByteN(input, 3);
|
||||
|
||||
(void)byte0;
|
||||
(void)byte1;
|
||||
(void)byte2;
|
||||
(void)byte3;
|
||||
|
||||
//std::cout << "Byte0 is " << ByteUtils::toString(byte0) << std::endl;
|
||||
//std::cout << "Byte1 is " << ByteUtils::toString(byte1) << std::endl;
|
||||
//std::cout << "Byte2 is " << ByteUtils::toString(byte2) << std::endl;
|
||||
//std::cout << "Byte3 is " << ByteUtils::toString(byte3) << std::endl;
|
||||
//std::cout << "Byte0 is " << Bits::toString(byte0) << std::endl;
|
||||
//std::cout << "Byte1 is " << Bits::toString(byte1) << std::endl;
|
||||
//std::cout << "Byte2 is " << Bits::toString(byte2) << std::endl;
|
||||
//std::cout << "Byte3 is " << Bits::toString(byte3) << std::endl;
|
||||
|
||||
//std::cout << "Mirroring" << std::endl;
|
||||
|
||||
//auto out = ByteUtils::mirror(byte);
|
||||
//std::cout << "Mirror is " << ByteUtils::toString(out) << std::endl;
|
||||
//auto out = Bits::mirror(byte);
|
||||
//std::cout << "Mirror is " << Bits::toString(out) << std::endl;
|
||||
|
||||
unsigned hold = byte;
|
||||
hold = (hold << 5) + 3;
|
||||
(void)hold;
|
||||
//std::cout << "Big val is " << ByteUtils::toString(hold, 16) << std::endl;
|
||||
//std::cout << "Big val is " << Bits::toString(hold, 16) << std::endl;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "File.h"
|
||||
#include "BitStream.h"
|
||||
#include "ByteUtils.h"
|
||||
#include "Bits.h"
|
||||
#include "Grid.h"
|
||||
#include "ImagePrimitives.h"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue