Imported Upstream version 1.71.0
[platform/upstream/boost.git] / libs / gil / test / pixel / test_fixture.cpp
1 //
2 // Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 #include <boost/config.hpp>
9 #include <boost/core/ignore_unused.hpp>
10
11 #if defined(BOOST_CLANG)
12 #pragma clang diagnostic push
13 #pragma clang diagnostic ignored "-Wconversion"
14 #pragma clang diagnostic ignored "-Wfloat-equal"
15 #pragma clang diagnostic ignored "-Wsign-conversion"
16 #elif BOOST_GCC >= 40700
17 #pragma GCC diagnostic push
18 #pragma GCC diagnostic ignored "-Wconversion"
19 #pragma GCC diagnostic ignored "-Wfloat-equal"
20 #pragma GCC diagnostic ignored "-Wsign-conversion"
21 #endif
22
23 #include <boost/gil/channel.hpp>
24
25 #include <limits>
26 #include <ostream>
27
28 #define BOOST_TEST_MODULE test_pixel_test_fixture
29 #include "unit_test.hpp"
30 #include "test_fixture.hpp"
31
32 namespace gil = boost::gil;
33 namespace fixture = boost::gil::test::fixture;
34
35 BOOST_AUTO_TEST_CASE_TEMPLATE(pixel_value_default_constructor, Pixel, fixture::pixel_types)
36 {
37     fixture::pixel_value<Pixel> fix;
38     Pixel const default_value{};
39     // FIXME: Default value of pixel/homogeneous_color_base is undermined
40     boost::ignore_unused(fix);
41     boost::ignore_unused(default_value);
42     //BOOST_TEST(fix.pixel_ == default_value);
43 }
44
45 BOOST_AUTO_TEST_CASE_TEMPLATE(pixel_value_parameterized_constructor, Pixel, fixture::pixel_types)
46 {
47     using channel_t = typename gil::channel_type<Pixel>::type;
48     // Sample channel value, simplified, could be min, max, random
49     channel_t const sample_channel = 2;
50     Pixel sample_pixel;
51     gil::static_fill(sample_pixel, sample_channel);
52     fixture::pixel_value<Pixel> fix{sample_pixel};
53     BOOST_TEST(fix.pixel_ == sample_pixel);
54 }
55
56 BOOST_AUTO_TEST_CASE_TEMPLATE(pixel_reference_default_constructor, Pixel, fixture::pixel_types)
57 {
58     fixture::pixel_reference<Pixel&> fix;
59     Pixel const default_value{};
60     // FIXME: Default value of pixel/homogeneous_color_base is undermined
61     boost::ignore_unused(fix);
62     boost::ignore_unused(default_value);
63     //BOOST_TEST(fix.pixel_ == Pixel{});
64 }
65
66 BOOST_AUTO_TEST_CASE_TEMPLATE(pixel_reference_parameterized_constructor, Pixel, fixture::pixel_types)
67 {
68     using channel_t = typename gil::channel_type<Pixel>::type;
69     // Sample channel value, simplified, could be min, max, random
70     channel_t const sample_channel = 3;
71     Pixel sample_pixel;
72     gil::static_fill(sample_pixel, sample_channel);
73     fixture::pixel_reference<Pixel&> fix{sample_pixel};
74     BOOST_TEST(fix.pixel_ == sample_pixel);
75 }