2
0
mirror of https://github.com/boostorg/gil.git synced 2026-02-19 14:32:10 +00:00
Files
gil/test/channel/channel_concepts.cpp
Mateusz Łoskot 32fec9f05b Refactor library includes to #include <boost/gil/...>
Group include directives, sort within group:
* In headers of GIL core and extensions:
  1. boost/gil/extension/*
  2. boost/gil/*
  3. boost/*
  4. C++ standard library headers
* In programs:
  1. boost/gil/*
  2. boost/*
  3. C++ standard library headers
  4. "xxx.hpp" for local headers
Add basic guidelines to CONTRIBUTING.md.
Add/Remove #include <boost/config.hpp> or std headers un/necessary.
Rename gil_concept.hpp to concepts.hpp.
Remove gil_all.hpp - we already have all-in-one boost/gil.hpp.
Tidy up and unify copyright and license header.
Tidy up formatting and excessive whitespaces in some comments.
Remove Doxygen block with file description, author, date, etc.
Remove dead or commented pragmas and directives.
Trim trailing whitespaces.
2018-09-28 16:26:34 +02:00

93 lines
3.0 KiB
C++

//
// Copyright 2005-2007 Adobe Systems Incorporated
// Copyright 2018 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 <cstdint>
#define BOOST_TEST_MODULE test_channel_concepts
#include <gil_test_common.hpp>
#include "channel_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*;
BOOST_STATIC_CONSTANT(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();
}
BOOST_AUTO_TEST_CASE(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&>();
}