Imported Upstream version 1.71.0
[platform/upstream/boost.git] / libs / gil / toolbox / test / channel_type.cpp
1 //
2 // Copyright 2013 Christian Henning
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/gil/extension/toolbox/metafunctions/channel_type.hpp>
9 #include <boost/gil/extension/toolbox/metafunctions/is_bit_aligned.hpp>
10
11 #include <boost/gil/channel.hpp> // boost::is_integral<packed_dynamic_channel_reference<...>>
12
13 #include <boost/test/unit_test.hpp>
14
15 #include <type_traits>
16
17 namespace bg = boost::gil;
18
19 BOOST_AUTO_TEST_SUITE(toolbox_tests)
20
21 BOOST_AUTO_TEST_CASE(channel_type_test)
22 {
23     static_assert(std::is_same
24         <
25             unsigned char,
26             bg::channel_type<bg::rgb8_pixel_t>::type
27         >::value, "");
28
29     // float32_t is a scoped_channel_value object
30     static_assert(std::is_same
31         <
32             bg::float32_t,
33             bg::channel_type<bg::rgba32f_pixel_t>::type
34         >::value, "");
35
36     // channel_type for bit_aligned images doesn't work with standard gil.
37     using image_t = bg::bit_aligned_image4_type<4, 4, 4, 4, bg::rgb_layout_t>::type;
38     using channel_t = bg::channel_type<image_t::view_t::reference>::type;
39     static_assert(boost::is_integral<channel_t>::value, "");
40 }
41
42 BOOST_AUTO_TEST_SUITE_END()