2
0
mirror of https://github.com/boostorg/gil.git synced 2026-01-20 04:32:25 +00:00
Files
gil/test/core/image_view/iterator.cpp
Mateusz Łoskot f641190948 Replace BOOST_TEST with BOOST_TEST_EQ for streamable operands (#472)
Improve utilities sending channels, pixels and other GIL objects to
output stream for logging of test errors.

Fix missing namespace qualification in IO tests.

Comment TARGA test case with FIXME that was accidentally
uncommented in cc64bdd1a4
2020-04-01 01:54:12 +02:00

96 lines
2.8 KiB
C++

//
// Copyright 2020 Mateusz Loskot <mateusz at loskot dot net>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/gil/image.hpp>
#include <boost/gil/image_view.hpp>
#include <boost/gil/typedefs.hpp>
#include <boost/core/lightweight_test.hpp>
#include "test_fixture.hpp"
#include "test_utility_output_stream.hpp"
namespace gil = boost::gil;
namespace fixture = boost::gil::test::fixture;
void test_begin()
{
{
gil::gray8_image_t image = fixture::make_image_gray8();
auto view = gil::view(image);
BOOST_TEST_EQ(*view.begin(), fixture::gray8_draw_pixel);
}
{
gil::rgb8_image_t image = fixture::make_image_rgb8();
auto view = gil::view(image);
BOOST_TEST_EQ(*view.begin(), fixture::rgb8_draw_pixel);
}
}
void test_end()
{
{
gil::gray8_image_t image;
auto view = gil::view(image);
BOOST_TEST(view.begin() == view.end());
}
{
gil::rgb8_image_t image;
auto view = gil::view(image);
BOOST_TEST(view.begin() == view.end());
}
}
void test_at()
{
{
gil::gray8_image_t image = fixture::make_image_gray8();
auto view = gil::view(image);
// begin
BOOST_TEST_EQ(*view.at(0), fixture::gray8_draw_pixel);
BOOST_TEST_EQ(*view.at(1), fixture::gray8_back_pixel);
BOOST_TEST_EQ(*view.at(0, 0), fixture::gray8_draw_pixel);
BOOST_TEST_EQ(*view.at(0, 1), fixture::gray8_back_pixel);
BOOST_TEST_EQ(*view.at(gil::point_t{0, 0}), fixture::gray8_draw_pixel);
BOOST_TEST_EQ(*view.at(gil::point_t{0, 1}), fixture::gray8_back_pixel);
// end
#ifdef NDEBUG // skip assertions
BOOST_TEST(view.at(4) == view.end());
// convoluted access to end iterator
BOOST_TEST(view.at(0, 2) == view.end());
BOOST_TEST(view.at(2, 1) == view.end());
#endif
}
{
gil::rgb8_image_t image = fixture::make_image_rgb8();
auto view = gil::view(image);
// begin
BOOST_TEST_EQ(*view.at(0), fixture::rgb8_draw_pixel);
BOOST_TEST_EQ(*view.at(1), fixture::rgb8_back_pixel);
BOOST_TEST_EQ(*view.at(0, 0), fixture::rgb8_draw_pixel);
BOOST_TEST_EQ(*view.at(0, 1), fixture::rgb8_back_pixel);
BOOST_TEST_EQ(*view.at(gil::point_t{0, 0}), fixture::rgb8_draw_pixel);
BOOST_TEST_EQ(*view.at(gil::point_t{0, 1}), fixture::rgb8_back_pixel);
// end
#ifdef NDEBUG // skip assertions
BOOST_TEST(view.at(4) == view.end());
// convoluted access to end iterator
BOOST_TEST(view.at(0, 2) == view.end());
BOOST_TEST(view.at(2, 1) == view.end());
#endif
}
}
int main()
{
test_begin();
test_end();
test_at();
return boost::report_errors();
}