mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-02-21 19:18:40 +01:00
clang-format
This commit is contained in:
@@ -75,35 +75,32 @@ TEST_CASE("test_apply_custom_weights") {
|
||||
CHECK_THAT(output, WithinAbs(6.34, 0.001));
|
||||
}
|
||||
|
||||
TEST_CASE("Mask 32 bit unsigned integer to 24 bit"){
|
||||
//any number less than 2**24 (16777216) should be the same
|
||||
CHECK(aare::mask32to24bits(0)==0);
|
||||
CHECK(aare::mask32to24bits(19)==19);
|
||||
CHECK(aare::mask32to24bits(29875)==29875);
|
||||
CHECK(aare::mask32to24bits(1092177)==1092177);
|
||||
CHECK(aare::mask32to24bits(0xFFFF)==0xFFFF);
|
||||
CHECK(aare::mask32to24bits(0xFFFFFFFF)==0xFFFFFF);
|
||||
TEST_CASE("Mask 32 bit unsigned integer to 24 bit") {
|
||||
// any number less than 2**24 (16777216) should be the same
|
||||
CHECK(aare::mask32to24bits(0) == 0);
|
||||
CHECK(aare::mask32to24bits(19) == 19);
|
||||
CHECK(aare::mask32to24bits(29875) == 29875);
|
||||
CHECK(aare::mask32to24bits(1092177) == 1092177);
|
||||
CHECK(aare::mask32to24bits(0xFFFF) == 0xFFFF);
|
||||
CHECK(aare::mask32to24bits(0xFFFFFFFF) == 0xFFFFFF);
|
||||
|
||||
// Offset specifies that the should ignore 0-7 bits
|
||||
// at the start
|
||||
CHECK(aare::mask32to24bits(0xFFFF, BitOffset(4))==0xFFF);
|
||||
CHECK(aare::mask32to24bits(0xFF0000d9)==0xd9);
|
||||
CHECK(aare::mask32to24bits(0xFF000d9F, BitOffset(4))==0xF000d9);
|
||||
CHECK(aare::mask32to24bits(16777217)==1);
|
||||
CHECK(aare::mask32to24bits(15,BitOffset(7))==0);
|
||||
|
||||
//Highest bit set to 1 should just be excluded
|
||||
//lowest 4 bits set to 1
|
||||
CHECK(aare::mask32to24bits(0x8000000f,BitOffset(7))==0);
|
||||
|
||||
CHECK(aare::mask32to24bits(0xFFFF, BitOffset(4)) == 0xFFF);
|
||||
CHECK(aare::mask32to24bits(0xFF0000d9) == 0xd9);
|
||||
CHECK(aare::mask32to24bits(0xFF000d9F, BitOffset(4)) == 0xF000d9);
|
||||
CHECK(aare::mask32to24bits(16777217) == 1);
|
||||
CHECK(aare::mask32to24bits(15, BitOffset(7)) == 0);
|
||||
|
||||
// Highest bit set to 1 should just be excluded
|
||||
// lowest 4 bits set to 1
|
||||
CHECK(aare::mask32to24bits(0x8000000f, BitOffset(7)) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("Expand container with 24 bit data to 32"){
|
||||
TEST_CASE("Expand container with 24 bit data to 32") {
|
||||
{
|
||||
uint8_t buffer[] = {
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
aare::NDView<uint8_t, 1> input(&buffer[0], {9});
|
||||
@@ -116,9 +113,7 @@ TEST_CASE("Expand container with 24 bit data to 32"){
|
||||
}
|
||||
{
|
||||
uint8_t buffer[] = {
|
||||
0x0F, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF,
|
||||
0x0F, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
|
||||
};
|
||||
|
||||
aare::NDView<uint8_t, 1> input(&buffer[0], {9});
|
||||
@@ -131,9 +126,7 @@ TEST_CASE("Expand container with 24 bit data to 32"){
|
||||
}
|
||||
{
|
||||
uint8_t buffer[] = {
|
||||
0x00, 0x00, 0xFF,
|
||||
0xFF, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0x00,
|
||||
0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
};
|
||||
|
||||
aare::NDView<uint8_t, 1> input(&buffer[0], {9});
|
||||
@@ -147,20 +140,16 @@ TEST_CASE("Expand container with 24 bit data to 32"){
|
||||
REQUIRE_THROWS(aare::expand24to32bit(input, out.view(), BitOffset(4)));
|
||||
}
|
||||
{
|
||||
//For use with offset we need an extra byte
|
||||
uint8_t buffer[] = {
|
||||
0x00, 0x00, 0xFF,
|
||||
0xFF, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00
|
||||
};
|
||||
// For use with offset we need an extra byte
|
||||
uint8_t buffer[] = {0x00, 0x00, 0xFF, 0xFF, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0x00};
|
||||
|
||||
aare::NDView<uint8_t, 1> input(&buffer[0], {10});
|
||||
aare::NDArray<uint32_t, 1> out({3}); //still output.size == 3
|
||||
aare::NDArray<uint32_t, 1> out({3}); // still output.size == 3
|
||||
aare::expand24to32bit(input, out.view(), BitOffset(4));
|
||||
|
||||
CHECK(out(0) == 0xFFF000);
|
||||
CHECK(out(1) == 0xFFF);
|
||||
CHECK(out(2) == 0xFF0);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user