CBORTest: Check content of arrays with/without compression

This commit is contained in:
2023-04-19 22:31:38 +02:00
parent 37b5d1a169
commit fae3cf5b42

View File

@@ -7,6 +7,7 @@
#include "../frame_serialize/JFJochFrameDeserializer.h"
#include "../compression/JFJochCompressor.h"
#include "stream2.h"
#include "../frame_serialize/CborUtil.h"
TEST_CASE("CBORSerialize_Start", "[CBOR]") {
JFJochFrameSerializer serializer(8*1024*1024);
@@ -471,6 +472,15 @@ TEST_CASE("CBORSerialize_Start_stream2", "[CBOR]") {
CHECK(msg2->frame_time == message.frame_time);
CHECK(msg2->count_time == message.count_time);
CHECK(msg2->pixel_mask_enabled == message.pixel_mask_enabled);
CHECK(msg2->pixel_mask.len == 1);
CHECK(CmpString(msg2->pixel_mask.ptr[0].channel, "sc0"));
CHECK(msg2->pixel_mask.ptr[0].pixel_mask.dim[0] == 457);
CHECK(msg2->pixel_mask.ptr[0].pixel_mask.dim[1] == 456);
CHECK(msg2->pixel_mask.ptr[0].pixel_mask.array.data.len == 456 * 457 * sizeof(uint32_t));
CHECK(memcmp(msg2->pixel_mask.ptr[0].pixel_mask.array.data.ptr, message.pixel_mask["sc0"].data(),
456 * 457 * sizeof(uint32_t)) == 0);
CHECK(msg2->pixel_mask.ptr[0].pixel_mask.array.tag == TagUnsignedInt32BitLE);
stream2_free_msg(msg);
}
@@ -516,10 +526,11 @@ TEST_CASE("CBORSerialize_Image_compressed_stream2", "[CBOR]") {
JFJochBitShuffleCompressor compressor(CompressionAlgorithm::BSHUF_LZ4);
compressor.Compress(compressed_test.data(), test);
size_t compressed_size = compressor.Compress(compressed_test.data(), test);
CBORImage image {
.data = compressed_test.data(),
.size = 1024 * 512,
.size = compressed_size,
.xpixel = 1024,
.ypixel = 512,
.pixel_depth_bytes = 2,
@@ -545,7 +556,15 @@ TEST_CASE("CBORSerialize_Image_compressed_stream2", "[CBOR]") {
auto msg2 = (stream2_image_msg *) msg;
CHECK(msg2->image_id == message.number);
CHECK(msg2->data.len == 1);
CHECK(CmpString(msg2->data.ptr[0].channel, "default"));
CHECK(msg2->data.ptr[0].data.dim[0] == 512);
CHECK(msg2->data.ptr[0].data.dim[1] == 1024);
CHECK(CmpString(msg2->data.ptr[0].data.array.data.compression.algorithm, "bslz4"));
CHECK(msg2->data.ptr[0].data.array.data.compression.elem_size == 2);
CHECK(msg2->data.ptr[0].data.array.data.compression.orig_size == 1024 * 512 * 2);
REQUIRE(msg2->data.ptr[0].data.array.data.len == compressed_size);
CHECK(memcmp(msg2->data.ptr[0].data.array.data.ptr, compressed_test.data(), compressed_size) == 0);
CHECK(msg2->data.ptr[0].data.array.tag == TagUnsignedInt16BitLE);
CHECK(msg2->series_id == message.series_id);
CHECK(CmpString(msg2->series_unique_id, message.series_unique_id));
stream2_free_msg(msg);
@@ -588,7 +607,11 @@ TEST_CASE("CBORSerialize_Image_uncompressed_stream2", "[CBOR]") {
auto msg2 = (stream2_image_msg *) msg;
CHECK(msg2->image_id == message.number);
CHECK(msg2->data.len == 1);
CHECK(CmpString(msg2->data.ptr->channel, "default"));
CHECK(msg2->data.ptr[0].data.array.data.compression.algorithm == nullptr);
REQUIRE(msg2->data.ptr[0].data.array.data.len == 512*1024);
CHECK(memcmp(msg2->data.ptr[0].data.array.data.ptr, test.data(), 512*1024) == 0);
CHECK(msg2->data.ptr[0].data.array.tag == TagUnsignedInt8Bit);
CHECK(msg2->series_id == message.series_id);
CHECK(CmpString(msg2->series_unique_id, message.series_unique_id));
stream2_free_msg(msg);