Clean up some test files.

This commit is contained in:
James Grogan 2022-11-30 18:28:50 +00:00
parent 1adc9272f8
commit b45385e8c7
51 changed files with 485 additions and 281 deletions

12
test/core/CMakeLists.txt Normal file
View file

@ -0,0 +1,12 @@
set(CORE_UNIT_TEST_FILES
core/TestByteUtils.cpp
core/TestBitStream.cpp
core/TestTomlReader.cpp
core/TestDataStructures.cpp
PARENT_SCOPE
)
set(CORE_UNIT_TEST_DEPENDENCIES
core
PARENT_SCOPE
)

View file

@ -21,22 +21,22 @@ TEST_CASE(TestReadBitStream, "core")
unsigned char buffer{0} ;
auto valid = stream.readNextNBits(1, buffer);
std::cout << "Slice0 is " << ByteUtils::toString(buffer) << std::endl;
//std::cout << "Slice0 is " << ByteUtils::toString(buffer) << std::endl;
valid = stream.readNextNBits(2, buffer);
std::cout << "Slice1 is " << ByteUtils::toString(buffer) << std::endl;
//std::cout << "Slice1 is " << ByteUtils::toString(buffer) << std::endl;
valid = stream.readNextNBits(5, buffer);
std::cout << "Slice2 is " << ByteUtils::toString(buffer) << std::endl;
//std::cout << "Slice2 is " << ByteUtils::toString(buffer) << std::endl;
valid = stream.readNextNBits(5, buffer);
std::cout << "Slice3 is " << ByteUtils::toString(buffer) << std::endl;
//std::cout << "Slice3 is " << ByteUtils::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 " << ByteUtils::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 " << ByteUtils::toString(buffer) << std::endl;
}
TEST_CASE(TestWritingBitStream, "core")
@ -68,9 +68,9 @@ TEST_CASE(TestWritingBitStream, "core")
auto byte3 = ByteUtils::toString(*stream.readNextByte());
auto byte4 = ByteUtils::toString(*stream.readNextByte());
std::cout << "Got bytes 0 " << byte0 << std::endl;
std::cout << "Got bytes 1 " << byte1 << std::endl;
std::cout << "Got bytes 2 " << byte2 << std::endl;
std::cout << "Got bytes 3 " << byte3 << std::endl;
std::cout << "Got bytes 4 " << byte4 << std::endl;
//std::cout << "Got bytes 0 " << byte0 << std::endl;
//std::cout << "Got bytes 1 " << byte1 << std::endl;
//std::cout << "Got bytes 2 " << byte2 << std::endl;
//std::cout << "Got bytes 3 " << byte3 << std::endl;
//std::cout << "Got bytes 4 " << byte4 << std::endl;
}

View file

@ -7,13 +7,13 @@
TEST_CASE(TestReadByteUtils, "core")
{
auto byte = ByteUtils::getFromString("00110101");
std::cout << "Value is " << static_cast<unsigned>(byte) << std::endl;
//std::cout << "Value is " << static_cast<unsigned>(byte) << std::endl;
auto string_rep = ByteUtils::toString(byte);
std::cout << "String rep is " << string_rep << std::endl;
//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;
//std::cout << "Slice is " << ByteUtils::toString(slice) << std::endl;
uint32_t input {12345678};
auto byte0 = ByteUtils::getByteN(input, 0);
@ -21,17 +21,17 @@ TEST_CASE(TestReadByteUtils, "core")
auto byte2 = ByteUtils::getByteN(input, 2);
auto byte3 = ByteUtils::getByteN(input, 3);
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 " << 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 << "Mirroring" << std::endl;
//std::cout << "Mirroring" << std::endl;
auto out = ByteUtils::mirror(byte);
std::cout << "Mirror is " << ByteUtils::toString(out) << std::endl;
//std::cout << "Mirror is " << ByteUtils::toString(out) << std::endl;
unsigned hold = byte;
hold = (hold << 5) + 3;
std::cout << "Big val is " << ByteUtils::toString(hold, 16) << std::endl;
//std::cout << "Big val is " << ByteUtils::toString(hold, 16) << std::endl;
}

View file

@ -10,25 +10,25 @@ TEST_CASE(TestCircleBuffer, "core")
for (auto item : {1, 2, 3})
{
std::cout << "Add item: " << item << std::endl;
//std::cout << "Add item: " << item << std::endl;
buffer.addItem(item);
}
for (std::size_t idx=0; idx<3; idx++)
{
auto item = buffer.getItem(idx);
std::cout << "Got item: " << idx << " " << item << std::endl;
//std::cout << "Got item: " << idx << " " << item << std::endl;
}
for (auto item : {4, 5})
{
std::cout << "Add item: " << item << std::endl;
buffer.addItem(item);
//std::cout << "Add item: " << item << std::endl;
//buffer.addItem(item);
}
for (std::size_t idx=0; idx<3; idx++)
{
auto item = buffer.getItem(idx);
std::cout << "Got item: " << idx << " " << item << std::endl;
//std::cout << "Got item: " << idx << " " << item << std::endl;
}
}

View file

@ -14,6 +14,9 @@ TEST_CASE(TestTomlReader, "core")
reader.read(sample_toml_file);
auto themes_table = reader.getContent()->getTable("themes");
REQUIRE(themes_table);
for (const auto& items : themes_table->getKeyValuePairs())
{
std::cout << "Got entry with key: " << items.first << " and val " << items.second << std::endl;