IRSOL
C++ code implementing socket server for interacting with Baumer camera.
test_binary.cpp
Go to the documentation of this file.
2
3#include <catch2/catch_all.hpp>
4#include <memory>
5#include <string>
6#include <utility>
7#include <vector>
8
9TEST_CASE("BinaryDataBuffer::BinaryDataBuffer()", "[Protocol][Protocol::Message]")
10{
11 auto size = GENERATE(static_cast<uint64_t>(10), static_cast<uint64_t>(1000));
12 {
13
14 std::vector<irsol::types::byte_t> data(
16 irsol::protocol::BinaryDataBuffer m{std::move(data), {size}};
18 STATIC_CHECK(m.BYTES_PER_ELEMENT == 2); // We work with image data with 16bits depth always.
21 }
22}
23
24TEST_CASE("ImageBinaryData::ImageBinaryData()", "[Protocol][Protocol::Message]")
25{
26 auto sizeData = GENERATE(
27 std::make_pair(
28 static_cast<uint64_t>(160),
29 std::array<uint64_t, 2>{static_cast<uint64_t>(10), static_cast<uint64_t>(16)}),
30 std::make_pair(
31 static_cast<uint64_t>(921600),
32 std::array<uint64_t, 2>{static_cast<uint64_t>(1280), static_cast<uint64_t>(720)}));
33 {
34 std::vector<irsol::types::byte_t> data(
36 irsol::protocol::ImageBinaryData m{std::move(data), sizeData.second};
37 STATIC_CHECK(m.DIM == 2);
38 STATIC_CHECK(m.BYTES_PER_ELEMENT == 2); // We work with image data with 16bits depth always.
39 CHECK(m.numElements == sizeData.first);
41 }
42}
43
44TEST_CASE("ColorImageBinaryData::ColorImageBinaryData()", "[Protocol][Protocol::Message]")
45{
46 auto sizeData = GENERATE(
47 std::make_pair(
48 static_cast<uint64_t>(160),
49 std::array<uint64_t, 3>{
50 static_cast<uint64_t>(10), static_cast<uint64_t>(16), static_cast<uint64_t>(1)}),
51 std::make_pair(
52 static_cast<uint64_t>(2764800),
53 std::array<uint64_t, 3>{
54 static_cast<uint64_t>(1280), static_cast<uint64_t>(720), static_cast<uint64_t>(3)}));
55 {
56 std::vector<irsol::types::byte_t> data(
58 irsol::protocol::ColorImageBinaryData m{std::move(data), sizeData.second};
59 STATIC_CHECK(m.DIM == 3);
60 STATIC_CHECK(m.BYTES_PER_ELEMENT == 2); // We work with image data with 16bits depth always.
61 CHECK(m.numElements == sizeData.first);
63 }
64}
Protocol binary data types and attributes definitions.
Represents a binary data object within the protocol.
Definition binary.hpp:107
static constexpr uint8_t BYTES_PER_ELEMENT
Number of bytes per element.
Definition binary.hpp:112
uint64_t numElements
Total number of elements in the data.
Definition binary.hpp:165
static constexpr uint8_t DIM
Dimensionality of the binary data.
Definition binary.hpp:115
uint64_t numBytes
Total number of bytes (numElements * bytes per element).
Definition binary.hpp:168
CHECK(m.numElements==size)
irsol::protocol::BinaryDataBuffer m
STATIC_CHECK(m.DIM==1)
TEST_CASE("Pixel<T>::max())", "[PixelFormat]")