4 #define BOOST_TEST_DYN_LINK
5 #define BOOST_TEST_MODULE MappedImageTest
11 #include <boost/test/unit_test.hpp>
13 using namespace boost::unit_test_framework;
16 BOOST_AUTO_TEST_SUITE(MappedImageTestSuite)
19 unsigned bufLen = 100;
41 BOOST_CHECK(h->totalLength ==
sizeof(AStruct));
44 BOOST_CHECK(ms1.
header()->x == 4.);
45 BOOST_CHECK(ms1.
header()->y == 1.);
51 BOOST_CHECK(ms.
header()->x == 4.);
58 unsigned w = 4, h = 2;
59 A0.
setShape(w, h, ImgFormat::Gray16);
70 BOOST_CHECK(val == 6);
73 for(
unsigned y = 0; y < h; y++) {
75 for(
auto* it = Av.beginRow(y); it != Av.endRow(y); ++it) {
76 BOOST_CHECK(*it == Av(x, y));
82 for(
auto& pixVal : Av) {
86 for(
auto& pixVal : Av) {
88 BOOST_CHECK(pixVal == counter);
92 auto* bufData0 = buf.data();
93 auto* head =
reinterpret_cast<ImgHeader*
>(bufData0);
94 BOOST_CHECK(head->width == w);
95 BOOST_CHECK(head->height == h);
96 BOOST_CHECK(head->image_format == ImgFormat::Gray16);
97 BOOST_CHECK(head->channels == 1);
98 BOOST_CHECK(head->bytesPerPixel == 2);
101 auto* imgBody =
reinterpret_cast<uint16_t*
>(buf.data() +
sizeof(
ImgHeader));
103 for(
auto& pixVal : Av) {
104 BOOST_CHECK(imgBody[i] == pixVal);
111 std::vector<unsigned char> buf1(buf.getNElements());
112 *
reinterpret_cast<ImgHeader*
>(buf1.data()) = head0;
113 auto* imgBody1 =
reinterpret_cast<uint16_t*
>(buf1.data() +
sizeof(
ImgHeader));
114 imgBody1[w * h - 1] = 42;
116 BOOST_CHECK(buf.data() != bufData0);
119 auto lastVal = Av(w - 1, h - 1);
120 BOOST_CHECK(lastVal == 42);
123 A0.
setShape(2, 1, ImgFormat::FLOAT2);
125 AvFloat2(0, 0, 1) = 0.1F;
126 AvFloat2(1, 0, 1) = 1.1F;
127 BOOST_TEST(AvFloat2(0, 0, 1) == 0.1
F);
128 BOOST_TEST(AvFloat2(1, 0, 1) == 1.1
F);
131 BOOST_AUTO_TEST_SUITE_END()