#include "common.hpp"
#include "Utils.hpp"
#include <catch2/catch.hpp>
SCENARIO("Utils::Byte")
{
uint8_t buffer[] =
{
0b00000000, 0b00000001, 0b00000010, 0b00000011,
0b10000000, 0b01000000, 0b00100000, 0b00010000,
0b01111111, 0b11111111, 0b11111111, 0b00000000,
0b11111111, 0b11111111, 0b11111111, 0b00000000,
0b10000000, 0b00000000, 0b00000000, 0b00000000
};
SECTION("Utils::Byte::Get3Bytes()")
{
REQUIRE(Utils::Byte::Get3Bytes(buffer, 4) == 8405024);
}
SECTION("Utils::Byte::Set3Bytes()")
{
Utils::Byte::Set3Bytes(buffer, 4, 5666777);
REQUIRE(Utils::Byte::Get3Bytes(buffer, 4) == 5666777);
}
SECTION("Utils::Byte::Get3BytesSigned()")
{
REQUIRE(Utils::Byte::Get3BytesSigned(buffer, 8) == 8388607);
REQUIRE(Utils::Byte::Get3BytesSigned(buffer, 12) == -1);
REQUIRE(Utils::Byte::Get3BytesSigned(buffer, 16) == -8388608);
}
SECTION("Utils::Byte::Set3BytesSigned()")
{
Utils::Byte::Set3BytesSigned(buffer, 0, 8388607);
REQUIRE(Utils::Byte::Get3BytesSigned(buffer, 0) == 8388607);
Utils::Byte::Set3BytesSigned(buffer, 0, -1);
REQUIRE(Utils::Byte::Get3BytesSigned(buffer, 0) == -1);
Utils::Byte::Set3BytesSigned(buffer, 0, -8388608);
REQUIRE(Utils::Byte::Get3BytesSigned(buffer, 0) == -8388608);
}
}