]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/gil/test/core/channel/test_fixture.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / gil / test / core / channel / test_fixture.cpp
index ea882400547c19aa0b7782887cf6f62b6a246c66..b8643a1e472cbfe63d3c849b2a807157f414e2d8 100644 (file)
 //
-// Copyright 2018 Mateusz Loskot <mateusz at loskot dot net>
+// Copyright 2018-2020 Mateusz Loskot <mateusz at loskot dot net>
 //
 // 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 <limits>
-
-#define BOOST_TEST_MODULE test_channel_test_fixture
-#include "unit_test.hpp"
 #include "test_fixture.hpp"
 
+#include <boost/core/lightweight_test.hpp>
+
+#include <limits>
+
 namespace fixture = boost::gil::test::fixture;
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(channel_minmax_value_integral, Channel, fixture::channel_integer_types)
+struct test_channel_minmax_value_float
 {
-    fixture::channel_minmax_value<Channel> fix;
-    fixture::channel_minmax_value<Channel> exp;
-    BOOST_TEST(fix.min_v_ == exp.min_v_);
-    BOOST_TEST(fix.max_v_ == exp.max_v_);
-    BOOST_TEST(fix.min_v_ == std::numeric_limits<Channel>::min());
-    BOOST_TEST(fix.max_v_ == std::numeric_limits<Channel>::max());
-}
+    template <typename Channel>
+    void operator()(Channel const &)
+    {
+        using channel_t = Channel;
+        fixture::channel_minmax_value<channel_t> fix;
+        fixture::channel_minmax_value<channel_t> exp;
+        BOOST_TEST_EQ(fix.min_v_, exp.min_v_);
+        BOOST_TEST_EQ(fix.max_v_, exp.max_v_);
+    }
+    static void run()
+    {
+        boost::mp11::mp_for_each<fixture::channel_bitfield_types>(test_channel_minmax_value_float{});
+    }
+};
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(channel_minmax_value_float, Channel, fixture::channel_float_types)
+struct test_channel_value
 {
-    fixture::channel_minmax_value<Channel> fix;
-    fixture::channel_minmax_value<Channel> exp;
-    BOOST_TEST(fix.min_v_ == exp.min_v_);
-    BOOST_TEST(fix.max_v_ == exp.max_v_);
-}
+    template <typename Channel>
+    void operator()(Channel const &)
+    {
+        using channel_t = Channel;
+        fixture::channel_value<channel_t> fix;
+        fixture::channel_minmax_value<channel_t> exp;
+        BOOST_TEST_EQ(fix.min_v_, exp.min_v_);
+        BOOST_TEST_EQ(fix.max_v_, exp.max_v_);
+    }
+    static void run()
+    {
+        boost::mp11::mp_for_each<fixture::channel_byte_types>(test_channel_value{});
+    }
+};
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(channel_value, Channel, fixture::channel_byte_types)
+struct test_channel_reference
 {
-    fixture::channel_value<Channel> fix;
-    fixture::channel_minmax_value<Channel> exp;
-    BOOST_TEST(fix.min_v_ == exp.min_v_);
-    BOOST_TEST(fix.max_v_ == exp.max_v_);
-}
+        template <typename Channel>
+    void operator()(Channel const&)
+    {
+        using channel_t = Channel;
+        fixture::channel_reference<channel_t &> fix;
+        fixture::channel_minmax_value<channel_t> exp;
+        BOOST_TEST_EQ(fix.min_v_, exp.min_v_);
+        BOOST_TEST_EQ(fix.max_v_, exp.max_v_);
+    }
+    static void run()
+    {
+        boost::mp11::mp_for_each<fixture::channel_byte_types>(test_channel_reference{});
+    }
+};
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(channel_reference, Channel, fixture::channel_byte_types)
+struct test_channel_reference_const
 {
-    fixture::channel_reference<Channel&> fix;
-    fixture::channel_minmax_value<Channel> exp;
-    BOOST_TEST(fix.min_v_ == exp.min_v_);
-    BOOST_TEST(fix.max_v_ == exp.max_v_);
-}
+    template <typename Channel>
+    void operator()(Channel const &)
+    {
+        using channel_t = Channel;
+        fixture::channel_reference<channel_t const &> fix;
+        fixture::channel_minmax_value<channel_t> exp;
+        BOOST_TEST_EQ(fix.min_v_, exp.min_v_);
+        BOOST_TEST_EQ(fix.max_v_, exp.max_v_);
+    }
+    static void run()
+    {
+        boost::mp11::mp_for_each<fixture::channel_byte_types>(test_channel_reference_const{});
+    }
+};
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(
-    channel_reference_const, Channel, fixture::channel_byte_types)
+struct test_packed_channels565
 {
-    fixture::channel_reference<Channel const&> fix;
-    fixture::channel_minmax_value<Channel> exp;
-    BOOST_TEST(fix.min_v_ == exp.min_v_);
-    BOOST_TEST(fix.max_v_ == exp.max_v_);
-}
+    template <typename BitField>
+    void operator()(BitField const &)
+    {
+        using bitfield_t = BitField;
+        static_assert(std::is_integral<bitfield_t>::value, "bitfield is not integral type");
+
+        // Regardless of BitField buffer bit-size, the fixture is initialized
+        // with max value that fits into 5+6+5 bit integer
+        fixture::packed_channels565<bitfield_t> fix;
+        fixture::channel_minmax_value<std::uint16_t> exp;
+        BOOST_TEST_EQ(fix.data_, exp.max_v_);
+    }
+    static void run()
+    {
+        boost::mp11::mp_for_each<fixture::channel_bitfield_types>(test_packed_channels565{});
+    }
+};
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(
-    packed_channels565, BitField, fixture::channel_bitfield_types)
+struct test_packed_dynamic_channels565
 {
-    static_assert(std::is_integral<BitField>::value, "bitfield is not integral type");
+    template <typename BitField>
+    void operator()(BitField const &)
+    {
+        using bitfield_t = BitField;
+        static_assert(std::is_integral<bitfield_t>::value, "bitfield is not integral type");
 
-    // Regardless of BitField buffer bit-size, the fixture is initialized
-    // with max value that fits into 5+6+5 bit integer
-    fixture::packed_channels565<BitField> fix;
-    fixture::channel_minmax_value<std::uint16_t> exp;
-    BOOST_TEST(fix.data_ == exp.max_v_);
-}
+        // Regardless of BitField buffer bit-size, the fixture is initialized
+        // with max value that fits into 5+6+5 bit integer
+        fixture::packed_dynamic_channels565<bitfield_t> fix;
+        fixture::channel_minmax_value<std::uint16_t> exp;
+        BOOST_TEST_EQ(fix.data_, exp.max_v_);
+    }
+    static void run()
+    {
+        boost::mp11::mp_for_each<fixture::channel_bitfield_types>(test_packed_dynamic_channels565{});
+    }
+};
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(
-    packed_dynamic_channels565, BitField, fixture::channel_bitfield_types)
+int main()
 {
-    static_assert(std::is_integral<BitField>::value, "bitfield is not integral type");
+    test_channel_minmax_value_float::run();
+    test_channel_value::run();
+    test_channel_reference::run();
+    test_channel_reference_const::run();
+    test_packed_channels565::run();
+    test_packed_dynamic_channels565::run();
 
-    // Regardless of BitField buffer bit-size, the fixture is initialized
-    // with max value that fits into 5+6+5 bit integer
-    fixture::packed_dynamic_channels565<BitField> fix;
-    fixture::channel_minmax_value<std::uint16_t> exp;
-    BOOST_TEST(fix.data_ == exp.max_v_);
+    return ::boost::report_errors();
 }