Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / gil / test / core / 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 "unit_test_utility.hpp"
31 #include "test_fixture.hpp"
32
33 namespace gil = boost::gil;
34 namespace fixture = boost::gil::test::fixture;
35
36 BOOST_AUTO_TEST_CASE_TEMPLATE(pixel_value_default_constructor, Pixel, fixture::pixel_types)
37 {
38     fixture::pixel_value<Pixel> fix;
39     Pixel const default_value{};
40     // FIXME: Default value of pixel/homogeneous_color_base is undermined
41     boost::ignore_unused(fix);
42     boost::ignore_unused(default_value);
43     //BOOST_TEST(fix.pixel_ == default_value);
44 }
45
46 BOOST_AUTO_TEST_CASE_TEMPLATE(pixel_value_parameterized_constructor, Pixel, fixture::pixel_types)
47 {
48     using channel_t = typename gil::channel_type<Pixel>::type;
49     // Sample channel value, simplified, could be min, max, random
50     channel_t const sample_channel = 2;
51     Pixel sample_pixel;
52     gil::static_fill(sample_pixel, sample_channel);
53     fixture::pixel_value<Pixel> fix{sample_pixel};
54     BOOST_TEST(fix.pixel_ == sample_pixel);
55 }
56
57 BOOST_AUTO_TEST_CASE_TEMPLATE(pixel_reference_default_constructor, Pixel, fixture::pixel_types)
58 {
59     fixture::pixel_reference<Pixel&> fix;
60     Pixel const default_value{};
61     // FIXME: Default value of pixel/homogeneous_color_base is undermined
62     boost::ignore_unused(fix);
63     boost::ignore_unused(default_value);
64     //BOOST_TEST(fix.pixel_ == Pixel{});
65 }
66
67 BOOST_AUTO_TEST_CASE_TEMPLATE(pixel_reference_parameterized_constructor, Pixel, fixture::pixel_types)
68 {
69     using channel_t = typename gil::channel_type<Pixel>::type;
70     // Sample channel value, simplified, could be min, max, random
71     channel_t const sample_channel = 3;
72     Pixel sample_pixel;
73     gil::static_fill(sample_pixel, sample_channel);
74     fixture::pixel_reference<Pixel&> fix{sample_pixel};
75     BOOST_TEST(fix.pixel_ == sample_pixel);
76 }