gil/test/extension/toolbox/channel_view.cpp
Mateusz Łoskot 96df5442bc
Move tests of extensions inside test/ directory (#302)
Split header tests accordingly i.e. test core headers as part of
core tests, numeric extension headers as part of numeric tests, etc.

It extends the convention of sub-directories already established in
`include/boost/gil` directory. It is sensible to follow it in other
areas of the source tree (i.e. `test/`, `doc/` and `benchmark/`).

Another important reason to move the tests is to enable removal of
the top-level `Jamfile` with all its definitions of test-specific
requirements.
The top-level `Jamfile` is not advised, especially if it specifies
build requirements like C++ language version.
Those affect non-tests builds e.g. documentation, causing failures
during generation of HTML documentation (leads to missing docs).

(cherry picked from develop branch commit 4ed7701b47)
2019-09-26 11:43:13 +02:00

44 lines
1.1 KiB
C++

//
// Copyright 2013 Christian Henning
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
#include <boost/gil.hpp>
#include <boost/gil/extension/toolbox/metafunctions/channel_view.hpp>
#include <boost/test/unit_test.hpp>
#include <type_traits>
namespace bg = boost::gil;
BOOST_AUTO_TEST_SUITE(toolbox_tests)
BOOST_AUTO_TEST_CASE(channel_view_test)
{
using image_t = bg::rgb8_image_t;
image_t img(100, 100);
using kth_channel_view_t
= bg::kth_channel_view_type<0, bg::rgb8_view_t::const_t>::type;
using channel_view_t
= bg::channel_view_type<bg::red_t, bg::rgb8_view_t::const_t>::type;
static_assert(std::is_same
<
kth_channel_view_t,
channel_view_t
>::value,
"");
kth_channel_view_t const kth0 = bg::kth_channel_view<0>(bg::const_view(img));
BOOST_TEST(kth0.num_channels() == 1u);
channel_view_t const red = bg::channel_view<bg::red_t>(bg::const_view(img));
BOOST_TEST(red.num_channels() == 1u);
}
BOOST_AUTO_TEST_SUITE_END()