1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
//
// 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 "test_fixture.hpp"
#include <boost/core/lightweight_test.hpp>
#include <limits>
namespace fixture = boost::gil::test::fixture;
struct test_channel_minmax_value_float
{
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{});
}
};
struct test_channel_value
{
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{});
}
};
struct test_channel_reference
{
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{});
}
};
struct test_channel_reference_const
{
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{});
}
};
struct test_packed_channels565
{
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{});
}
};
struct test_packed_dynamic_channels565
{
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_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{});
}
};
int main()
{
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();
return ::boost::report_errors();
}
|