2
0
mirror of https://github.com/boostorg/gil.git synced 2026-02-01 20:42:10 +00:00
Files
gil/test/pixel/test_fixture.cpp
Mateusz Łoskot b1998d9a74 Add pixel test fixture with all core pixel types (#248)
Add test for pixel_reference_is_mutable metafunction.

From the legacy tests
- port value_core and reference_core fixtures, see
  https://lists.boost.org/boost-gil/2019/02/0138.php
- port representative pixel types and verify with tests of some
  metafunctions.

Clean up test names for CTest in the CMake configuration.
Disable some GCC/clang warnings in tests to avoid CI build
termination due to too long logs.
2019-03-02 23:18:54 +01:00

71 lines
2.3 KiB
C++

//
// Copyright 2019 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/config.hpp>
#if defined(BOOST_CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wfloat-equal"
#pragma clang diagnostic ignored "-Wsign-conversion"
#elif BOOST_GCC >= 40700
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wfloat-equal"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
#include <boost/gil/channel.hpp>
#include <limits>
#include <ostream>
#define BOOST_TEST_MODULE test_pixel_test_fixture
#include "unit_test.hpp"
#include "test_fixture.hpp"
namespace gil = boost::gil;
namespace fixture = boost::gil::test::fixture;
BOOST_AUTO_TEST_CASE_TEMPLATE(pixel_value_default_constructor, Pixel, fixture::pixel_types)
{
fixture::pixel_value<Pixel> fix;
Pixel const default_value{};
// FIXME: Default value of pixel/homogeneous_color_base is undermined
//BOOST_TEST(fix.pixel_ == default_value);
}
BOOST_AUTO_TEST_CASE_TEMPLATE(pixel_value_parameterized_constructor, Pixel, fixture::pixel_types)
{
using channel_t = typename gil::channel_type<Pixel>::type;
// Sample channel value, simplified, could be min, max, random
channel_t const sample_channel = 2;
Pixel sample_pixel;
gil::static_fill(sample_pixel, sample_channel);
fixture::pixel_value<Pixel> fix{sample_pixel};
BOOST_TEST(fix.pixel_ == sample_pixel);
}
BOOST_AUTO_TEST_CASE_TEMPLATE(pixel_reference_default_constructor, Pixel, fixture::pixel_types)
{
fixture::pixel_reference<Pixel&> fix;
Pixel const default_value{};
// FIXME: Default value of pixel/homogeneous_color_base is undermined
//BOOST_TEST(fix.pixel_ == Pixel{});
}
BOOST_AUTO_TEST_CASE_TEMPLATE(pixel_reference_parameterized_constructor, Pixel, fixture::pixel_types)
{
using channel_t = typename gil::channel_type<Pixel>::type;
// Sample channel value, simplified, could be min, max, random
channel_t const sample_channel = 3;
Pixel sample_pixel;
gil::static_fill(sample_pixel, sample_channel);
fixture::pixel_reference<Pixel&> fix{sample_pixel};
BOOST_TEST(fix.pixel_ == sample_pixel);
}