2 // Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
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
8 #include <boost/gil/color_base.hpp>
9 #include <boost/gil/gray.hpp>
10 #include <boost/gil/rgb.hpp>
11 #include <boost/gil/rgba.hpp>
13 #include <boost/core/typeinfo.hpp>
15 #include <type_traits>
17 #define BOOST_TEST_MODULE test_channel_traits
18 #include "unit_test.hpp"
20 namespace gil
= boost::gil
;
24 // Unknown layout is used where layout mapping is irrelevant for a test and its result.
25 using unknown_layout_t
= gil::gray_layout_t
;
28 using color_base
= gil::detail::homogeneous_color_base
<std::uint8_t, unknown_layout_t
, N
>;
30 std::integral_constant
<int, 0> e0
;
31 std::integral_constant
<int, 1> e1
;
32 std::integral_constant
<int, 2> e2
;
33 std::integral_constant
<int, 3> e3
;
34 std::integral_constant
<int, 4> e4
;
36 } // unnamed namespace
38 BOOST_AUTO_TEST_CASE(homogeneous_color_base_1_default_constructor
)
40 using fixture
= color_base
<1>;
42 BOOST_TEST(std::uint8_t{f
} == std::uint8_t{0});
43 BOOST_TEST(f
.at(e0
) == std::uint8_t{0});
46 BOOST_AUTO_TEST_CASE(homogeneous_color_base_1_value_constructor
)
48 using fixture
= color_base
<1>;
50 BOOST_TEST(std::uint8_t{f
} == std::uint8_t{1});
51 BOOST_TEST(f
.at(e0
) == std::uint8_t{1});
54 BOOST_AUTO_TEST_CASE(homogeneous_color_base_2_default_constructor
)
56 using fixture
= color_base
<2>;
58 BOOST_TEST(f
.at(e0
) == std::uint8_t{0});
59 BOOST_TEST(f
.at(e1
) == std::uint8_t{0});
62 BOOST_AUTO_TEST_CASE(homogeneous_color_base_2_value_constructor
)
64 using fixture
= color_base
<2>;
66 BOOST_TEST(f
.at(e0
) == std::uint8_t{2});
67 BOOST_TEST(f
.at(e0
) == f
.at(e1
));
70 BOOST_AUTO_TEST_CASE(homogeneous_color_base_3_default_constructor
)
72 using fixture
= color_base
<3>;
74 BOOST_TEST(f
.at(e0
) == std::uint8_t{0});
75 BOOST_TEST(f
.at(e1
) == std::uint8_t{0});
76 BOOST_TEST(f
.at(e2
) == std::uint8_t{0});
79 BOOST_AUTO_TEST_CASE(homogeneous_color_base_3_value_constructor
)
81 using fixture
= color_base
<3>;
83 BOOST_TEST(f
.at(e0
) == std::uint8_t{3});
84 BOOST_TEST(f
.at(e0
) == f
.at(e1
));
85 BOOST_TEST(f
.at(e0
) == f
.at(e2
));
88 BOOST_AUTO_TEST_CASE(homogeneous_color_base_4_default_constructor
)
90 using fixture
= color_base
<4>;
92 BOOST_TEST(f
.at(e0
) == std::uint8_t{0});
93 BOOST_TEST(f
.at(e1
) == std::uint8_t{0});
94 BOOST_TEST(f
.at(e2
) == std::uint8_t{0});
95 BOOST_TEST(f
.at(e3
) == std::uint8_t{0});
98 BOOST_AUTO_TEST_CASE(homogeneous_color_base_4_value_constructor
)
100 using fixture
= color_base
<4>;
102 BOOST_TEST(f
.at(e0
) == std::uint8_t{4});
103 BOOST_TEST(f
.at(e0
) == f
.at(e1
));
104 BOOST_TEST(f
.at(e0
) == f
.at(e2
));
105 BOOST_TEST(f
.at(e0
) == f
.at(e3
));
108 BOOST_AUTO_TEST_CASE(homogeneous_color_base_5_default_constructor
)
110 using fixture
= color_base
<5>;
112 BOOST_TEST(f
.at(e0
) == std::uint8_t{0});
113 BOOST_TEST(f
.at(e1
) == std::uint8_t{0});
114 BOOST_TEST(f
.at(e2
) == std::uint8_t{0});
115 BOOST_TEST(f
.at(e3
) == std::uint8_t{0});
116 BOOST_TEST(f
.at(e4
) == std::uint8_t{0});
119 BOOST_AUTO_TEST_CASE(homogeneous_color_base_5_value_constructor
)
121 using fixture
= color_base
<5>;
123 BOOST_TEST(f
.at(e0
) == f
.at(e1
));
124 BOOST_TEST(f
.at(e0
) == f
.at(e2
));
125 BOOST_TEST(f
.at(e0
) == f
.at(e3
));
126 BOOST_TEST(f
.at(e0
) == f
.at(e4
));