2022-11-22 17:37:06 +00:00
|
|
|
#include "ByteUtils.h"
|
|
|
|
|
2022-11-29 18:00:19 +00:00
|
|
|
#include "TestFramework.h"
|
|
|
|
|
2022-11-22 17:37:06 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2022-11-29 18:00:19 +00:00
|
|
|
TEST_CASE(TestReadByteUtils, "core")
|
2022-11-22 17:37:06 +00:00
|
|
|
{
|
|
|
|
auto byte = ByteUtils::getFromString("00110101");
|
|
|
|
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;
|
|
|
|
|
|
|
|
auto slice = ByteUtils::getMBitsAtN(byte, 3, 3);
|
|
|
|
std::cout << "Slice is " << ByteUtils::toString(slice) << std::endl;
|
|
|
|
|
2022-11-23 17:51:36 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
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;
|
2022-11-22 17:37:06 +00:00
|
|
|
|
2022-11-28 10:16:04 +00:00
|
|
|
std::cout << "Mirroring" << std::endl;
|
|
|
|
|
|
|
|
auto out = ByteUtils::mirror(byte);
|
|
|
|
std::cout << "Mirror is " << ByteUtils::toString(out) << std::endl;
|
|
|
|
|
2022-11-28 18:05:39 +00:00
|
|
|
unsigned hold = byte;
|
|
|
|
hold = (hold << 5) + 3;
|
|
|
|
std::cout << "Big val is " << ByteUtils::toString(hold, 16) << std::endl;
|
2022-11-22 17:37:06 +00:00
|
|
|
}
|