Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / gil / test / core / pixel / is_pixel.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/gil/bit_aligned_pixel_reference.hpp>
9 #include <boost/gil/packed_pixel.hpp>
10 #include <boost/gil/pixel.hpp>
11 #include <boost/gil/rgb.hpp>
12 #include <boost/gil/typedefs.hpp>
13 #include <boost/gil/concepts/pixel.hpp>
14
15 #include <boost/mp11.hpp>
16
17 #include "test_fixture.hpp"
18
19 namespace gil = boost::gil;
20 using namespace boost::mp11;
21
22 int main()
23 {
24     static_assert(std::is_same
25         <
26             mp_all_of<gil::test::fixture::pixel_typedefs, gil::is_pixel>,
27             std::true_type
28         >::value,
29         "is_pixel does not yield true for all core pixel types");
30
31     static_assert(std::is_same
32         <
33             mp_all_of
34             <
35                 mp_transform
36                 <
37                     gil::test::fixture::nested_pixel_type,
38                     gil::test::fixture::representative_pixel_types
39                 >,
40                 gil::is_pixel
41             >,
42             std::true_type
43         >::value,
44         "is_pixel does not yield true for representative pixel types");
45
46     static_assert(std::is_same
47         <
48             mp_all_of<gil::test::fixture::non_pixels, gil::is_pixel>,
49             std::false_type
50         >::value,
51         "is_pixel yields true for non-pixel type");
52
53     static_assert(std::is_same
54         <
55             mp_none_of<gil::test::fixture::non_pixels, gil::is_pixel>,
56             std::true_type
57         >::value,
58         "is_pixel yields true for non-pixel type");
59
60     using bgr121_ref_t = gil::bit_aligned_pixel_reference
61         <
62             std::uint8_t, mp_list_c<int, 1, 2, 1>, gil::bgr_layout_t, true
63         >;
64     static_assert(gil::is_pixel<bgr121_ref_t>::value,
65         "is_pixel does not yield true for bit_aligned_pixel_reference");
66
67     using rgb121_ref_t = gil::bit_aligned_pixel_reference
68         <
69             std::uint8_t, mp_list_c<int, 1, 2, 1>, gil::rgb_layout_t, true
70         >;
71     static_assert(gil::is_pixel<bgr121_ref_t>::value,
72         "is_pixel does not yield true for bit_aligned_pixel_reference");
73
74     using rgb121_packed_pixel_t = rgb121_ref_t::value_type;
75     static_assert(gil::is_pixel<rgb121_packed_pixel_t>::value,
76         "is_pixel does not yield true for packed_pixel");
77 }