2
0
mirror of https://github.com/boostorg/gil.git synced 2026-01-23 17:42:30 +00:00
Files
gil/test/core/channel/concepts.cpp
Mateusz Łoskot dda885e5ff Replace Boost.Test with Boost.LightweightTest in test/ (#459)
Motivation is to:
- use on simpler and light test framework,
- eliminate dependency on libraries like Boost.MPL,
- achieve faster compilation times for CI builds (20% seems feasible)
- have test programs easy to run and debug
- avoid macros

Remove outdated FIXME-s for bugs that have been already fixed.
Fix off-by-one bug in test/core/test_fixture.hpp generators.
Minor corrections and tidying up.

Add missing test assertions to numeric extension tests.
Fixes #458
2020-03-21 22:53:09 +01:00

101 lines
3.0 KiB
C++

//
// Copyright 2005-2007 Adobe Systems Incorporated
// 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 <boost/gil/concepts.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstdint>
#include "test_fixture.hpp"
namespace gil = boost::gil;
namespace fixture = boost::gil::test::fixture;
// A channel archetype - to test the minimum requirements of the concept
struct channel_value_archetype;
struct channel_archetype
{
// equality comparable
friend bool operator==(channel_archetype const&, channel_archetype const&)
{ return true; }
// inequality comparable
friend bool operator!=(channel_archetype const&, channel_archetype const&)
{ return false; }
// less-than comparable
friend bool operator<(channel_archetype const&, channel_archetype const&)
{ return false; }
// convertible to a scalar
operator std::uint8_t() const { return 0; }
channel_archetype& operator++() { return *this; }
channel_archetype& operator--() { return *this; }
channel_archetype operator++(int) { return *this; }
channel_archetype operator--(int) { return *this; }
template <typename Scalar>
channel_archetype operator+=(Scalar) { return *this; }
template <typename Scalar>
channel_archetype operator-=(Scalar) { return *this; }
template <typename Scalar>
channel_archetype operator*=(Scalar) { return *this; }
template <typename Scalar>
channel_archetype operator/=(Scalar) { return *this; }
using value_type = channel_value_archetype;
using reference = channel_archetype;
using const_reference = channel_archetype const;
using pointer = channel_value_archetype*;
using const_pointer = channel_value_archetype const*;
static constexpr bool is_mutable = true;
static value_type min_value();
static value_type max_value();
};
struct channel_value_archetype : public channel_archetype
{
// default constructible
channel_value_archetype() {}
// copy constructible
channel_value_archetype(channel_value_archetype const&) = default;
// assignable
channel_value_archetype& operator=(channel_value_archetype const&)
{return *this;}
channel_value_archetype(std::uint8_t) {}
};
channel_value_archetype channel_archetype::min_value()
{
return channel_value_archetype();
}
channel_value_archetype channel_archetype::max_value()
{
return channel_value_archetype();
}
void test_channel_minimal_requirements()
{
// Do only compile-time tests for the archetype
// (because asserts like val1<val2 fail)
boost::function_requires<gil::MutableChannelConcept<channel_archetype>>();
fixture::channel_value<channel_value_archetype>();
fixture::channel_reference<channel_archetype>();
fixture::channel_reference<channel_archetype const&>();
}
int main()
{
test_channel_minimal_requirements();
return ::boost::report_errors();
}