IRSOL
C++ code implementing socket server for interacting with Baumer camera.
test_pixel_format.cpp File Reference
#include "irsol/camera/pixel_format.hpp"
#include <catch2/catch_all.hpp>
#include <vector>

Go to the source code of this file.

Functions

 TEST_CASE ("Pixel<T>::max())", "[PixelFormat]")
 
 TEST_CASE ("PixelConversion<>::scale<T>())", "[PixelFormat]")
 
 TEST_CASE ("PixelByteSwapper<true>-swaps-bytes-for-16-bit-data", "[PixelFormat]")
 
 TEST_CASE ("PixelByteSwapper<false>-is-no-op", "[PixelFormat]")
 

Function Documentation

◆ TEST_CASE() [1/4]

TEST_CASE ( "Pixel<T>  ::max())

Definition at line 6 of file test_pixel_format.cpp.

7{
11}
Represents a pixel with a given bit depth.
STATIC_CHECK(m.DIM==1)

◆ TEST_CASE() [2/4]

TEST_CASE ( "PixelByteSwapper<false>-is-no-op"  ,
""  [PixelFormat] 
)

Definition at line 102 of file test_pixel_format.cpp.

103{
104
105 SECTION("No-op on empty vector")
106 {
107 std::vector<irsol::types::byte_t> v;
108 irsol::camera::PixelByteSwapper<false>()(v.begin(), v.end());
109 CHECK(v.empty());
110 }
111
112 SECTION("No-op on non-empty vector")
113 {
114 std::vector<irsol::types::byte_t> v = {irsol::types::byte_t{0x01},
118 irsol::camera::PixelByteSwapper<false>()(v.begin(), v.end());
119 CHECK(
120 v == std::vector<irsol::types::byte_t>{irsol::types::byte_t{0x01},
123 irsol::types::byte_t{0x04}});
124 }
125}
std::byte byte_t
Alias for a single byte used in serialization or binary data handling.
Definition types.hpp:165
Utility for swapping pixel bytes in a buffer.
CHECK(m.identifier==identifier)

◆ TEST_CASE() [3/4]

TEST_CASE ( "PixelByteSwapper<true>-swaps-bytes-for-16-bit-data"  ,
""  [PixelFormat] 
)

Definition at line 23 of file test_pixel_format.cpp.

24{
25
26 SECTION("Empty range does nothing")
27 {
28 std::vector<irsol::types::byte_t> v;
29 irsol::camera::PixelByteSwapper<true>()(v.begin(), v.end());
30 CHECK(v.empty());
31 }
32
33 SECTION("Begin after end raises an assertion")
34 {
35 std::vector<irsol::types::byte_t> v = {irsol::types::byte_t{0x01}, irsol::types::byte_t{0x02}};
38 }
39
40 SECTION("Even number of bytes swaps pairs")
41 {
42 std::vector<irsol::types::byte_t> v = {irsol::types::byte_t{0x01},
46 irsol::camera::PixelByteSwapper<true>()(v.begin(), v.end());
47 CHECK(
48 v == std::vector<irsol::types::byte_t>{irsol::types::byte_t{0x02},
52 }
53
54 SECTION("Odd number of bytes swaps pairs, last byte untouched")
55 {
56 std::vector<irsol::types::byte_t> v = {
58 irsol::camera::PixelByteSwapper<true>()(v.begin(), v.end());
59 CHECK(
60 v == std::vector<irsol::types::byte_t>{
62 }
63
64 SECTION("Single byte does nothing")
65 {
66 std::vector<irsol::types::byte_t> v = {irsol::types::byte_t{0xAA}};
67 irsol::camera::PixelByteSwapper<true>()(v.begin(), v.end());
68 CHECK(v == std::vector<irsol::types::byte_t>{irsol::types::byte_t{0xAA}});
69 }
70
71 SECTION("Longer vector swaps all pairs correctly")
72 {
73 std::vector<irsol::types::byte_t> v = {irsol::types::byte_t{0x01},
85 irsol::camera::PixelByteSwapper<true>()(v.begin(), v.end());
86 CHECK(
87 v == std::vector<irsol::types::byte_t>{irsol::types::byte_t{0x02},
99 }
100}
ppk::assert::AssertionException AssertionException
Definition assert.hpp:149
CHECK_THROWS_AS(irsol::protocol::Assignment(identifier, value), std::invalid_argument)

◆ TEST_CASE() [4/4]

TEST_CASE ( "PixelConversion<>::scale<T>  ())

Definition at line 13 of file test_pixel_format.cpp.