Commit f1be63c8 authored by Michaël Roynard's avatar Michaël Roynard
Browse files

Fix OutputImage concept

Fix unit tests image concept
Use archetype for all concept unit tests
Fix useless doc pages
parent 8ef2a2ba
Pipeline #12397 passed with stages
in 13 minutes and 20 seconds
......@@ -62,11 +62,6 @@ Core Module
* :ref:`Point <concept-points-Point>`
.. topic:: Predefined points
* :doc:`core/points/point2d`
* :doc:`core/points/point3d`
......@@ -82,10 +77,6 @@ Core Module
* :ref:`Pixel <concept-pixels-Pixel>`
.. topic:: Predefined points
* :doc:`core/pixels/ndpixel`
......@@ -101,11 +92,6 @@ Core Module
* :ref:`Domain <concept-domains-Domain>`
.. topic:: Predefined domains
* :doc:`core/domains/box2d`
* :doc:`core/domains/box3d`
......
================
Images (details)
================
TODO
......@@ -70,16 +70,6 @@ Then we have the following valid expressions :
Predefined domains
------------------
.. toctree::
domains/box2d
domains/box3d
Concepts detail
---------------
......
Box3D
=====
\ No newline at end of file
......@@ -74,16 +74,6 @@ If the `value_type` is constant then the value returned by `value()` (which retu
Predefined pixels
-----------------
.. toctree::
pixels/ndpixel
Concepts detail
---------------
......
......@@ -55,17 +55,6 @@ Then we have the following valid expressions :
Predefined points
-----------------
.. toctree::
points/point2d
points/point3d
Concepts detail
---------------
......
......@@ -77,7 +77,7 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputImage final : Image
struct OutputImage : Image
{
using new_pixel_type = OutputPixel;
using new_reference = pixel_reference_t<OutputPixel>;
......@@ -120,6 +120,16 @@ namespace mln::archetypes
#endif // PYLENE_CONCEPT_TS_ENABLED
struct OutputForwardImage final : OutputImage
{
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::ForwardImage<OutputForwardImage> && mln::concepts::OutputImage<OutputForwardImage>,
"OutputForwardImage archetype does not model the OutputImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct IndexableImage : Image
{
using index_type = int;
......@@ -161,7 +171,7 @@ namespace mln::archetypes
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::IndexableImage<OutputIndexableImage> && mln::concepts::OutputImage<OutputIndexableImage>,
"OutputIndexableImage archetype does not model the OutputImageconcept!");
"OutputIndexableImage archetype does not model the OutputImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
......@@ -358,4 +368,22 @@ namespace mln::archetypes
"OutputRawImage archetype does not model the OutputImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
struct ExtendedImage : Image
{
struct Extension
{
};
using extension_type = Extension;
using extension_category = mln::extension::custom_extension_tag;
image_extension_t<ExtendedImage> extension() const;
};
#ifdef PYLENE_CONCEPT_TS_ENABLED
static_assert(mln::concepts::ExtendedImage<ExtendedImage>,
"ExtendedImage archetype does not model the ExtendedImage concept!");
#endif // PYLENE_CONCEPT_TS_ENABLED
} // namespace mln::archetypes
......@@ -12,15 +12,15 @@
#ifdef PYLENE_CONCEPT_TS_ENABLED
#ifdef concept
#define __concept
#define __concept_bool
#undef concept
#endif
#include <stl2/concepts.hpp>
#ifdef __concept
#ifdef __concept_bool
#define concept concept bool
#undef __concept
#undef __concept_bool
#endif
namespace mln::concepts::stl
......
......@@ -217,10 +217,14 @@ namespace mln::concepts
// Usage: RawImage<I> && OutputImage<I>
template <typename Ima>
concept OutputImage =
(Image<Ima> && detail::WritableImage<Ima>) || // alias for Image and ForwardImage
(IndexableImage<Ima> && detail::WritableIndexableImage<Ima>) ||
(AccessibleImage<Ima> && detail::WritableAccessibleImage<Ima>) ||
(BidirectionalImage<Ima> && detail::WritableBidirectionalImage<Ima>) ||
(Image<Ima>&& detail::WritableImage<Ima> && not IndexableImage<Ima> && not AccessibleImage<Ima> &&
not BidirectionalImage<Ima> && not RawImage<Ima>) ||
(IndexableImage<Ima> && detail::WritableIndexableImage<Ima> && not AccessibleImage<Ima> &&
not BidirectionalImage<Ima> && not RawImage<Ima>) ||
(AccessibleImage<Ima> && detail::WritableAccessibleImage<Ima> && not IndexableImage<Ima> &&
not BidirectionalImage<Ima> && not RawImage<Ima>) ||
(BidirectionalImage<Ima> && detail::WritableBidirectionalImage<Ima> && not IndexableImage<Ima> &&
not AccessibleImage<Ima> && not RawImage<Ima>) ||
(RawImage<Ima> && detail::WritableRawImage<Ima>);
......
#include <mln/core/concept/new/archetype/domain.hpp>
#include <mln/core/concept/new/domains.hpp>
#include <gtest/gtest.h>
namespace concepts = mln::concepts;
namespace concepts = mln::concepts;
namespace archetypes = mln::archetypes;
struct A
{
};
struct mock_domain
{
struct mock_point
{
};
using value_type = mock_point;
using reference = mock_point&;
value_type* begin();
value_type* end();
bool has(value_type) const;
bool empty() const;
unsigned size() const;
};
bool operator==(const mock_domain::mock_point&, const mock_domain::mock_point&);
bool operator!=(const mock_domain::mock_point&, const mock_domain::mock_point&);
bool operator<(const mock_domain::mock_point&, const mock_domain::mock_point&);
bool operator<=(const mock_domain::mock_point&, const mock_domain::mock_point&);
bool operator>(const mock_domain::mock_point&, const mock_domain::mock_point&);
bool operator>=(const mock_domain::mock_point&, const mock_domain::mock_point&);
TEST(Core, Concept_Domain)
{
static_assert(!concepts::Domain<int>);
static_assert(!concepts::Domain<A>);
static_assert(concepts::Domain<mock_domain>);
static_assert(concepts::Domain<archetypes::Domain>);
}
#include <mln/core/concept/new/images.hpp>
#include <mln/core/concept/new/archetype/image.hpp>
#include <mln/core/concept/new/images.hpp>
#include <gtest/gtest.h>
......@@ -7,11 +7,230 @@
#include <type_traits>
namespace concepts = mln::concepts;
namespace concepts = mln::concepts;
namespace archetypes = mln::archetypes;
TEST(Core, Concept_Image)
{
static_assert(concepts::Image<archetypes::Image>);
static_assert(concepts::Image<archetypes::ForwardImage>);
static_assert(concepts::Image<archetypes::InputImage>);
static_assert(concepts::Image<archetypes::IndexableImage>);
static_assert(concepts::Image<archetypes::AccessibleImage>);
static_assert(concepts::Image<archetypes::BidirectionalImage>);
static_assert(concepts::Image<archetypes::RawImage>);
}
TEST(Core, Concept_ForwardImage)
{
static_assert(concepts::ForwardImage<archetypes::Image>);
static_assert(concepts::ForwardImage<archetypes::ForwardImage>);
static_assert(concepts::ForwardImage<archetypes::InputImage>);
static_assert(concepts::ForwardImage<archetypes::IndexableImage>);
static_assert(concepts::ForwardImage<archetypes::AccessibleImage>);
static_assert(concepts::ForwardImage<archetypes::BidirectionalImage>);
static_assert(concepts::ForwardImage<archetypes::RawImage>);
}
TEST(Core, Concept_InputImage)
{
static_assert(concepts::InputImage<archetypes::Image>);
static_assert(concepts::InputImage<archetypes::ForwardImage>);
static_assert(concepts::InputImage<archetypes::InputImage>);
static_assert(concepts::InputImage<archetypes::IndexableImage>);
static_assert(concepts::InputImage<archetypes::AccessibleImage>);
static_assert(concepts::InputImage<archetypes::BidirectionalImage>);
static_assert(concepts::InputImage<archetypes::RawImage>);
}
TEST(Core, Concept_IndexableImage)
{
static_assert(not concepts::IndexableImage<archetypes::Image>);
static_assert(not concepts::IndexableImage<archetypes::ForwardImage>);
static_assert(not concepts::IndexableImage<archetypes::InputImage>);
static_assert(concepts::IndexableImage<archetypes::IndexableImage>);
static_assert(not concepts::IndexableImage<archetypes::AccessibleImage>);
static_assert(not concepts::IndexableImage<archetypes::BidirectionalImage>);
static_assert(concepts::IndexableImage<archetypes::RawImage>);
}
TEST(Core, Concept_AccessibleImage)
{
static_assert(not concepts::AccessibleImage<archetypes::Image>);
static_assert(not concepts::AccessibleImage<archetypes::ForwardImage>);
static_assert(not concepts::AccessibleImage<archetypes::InputImage>);
static_assert(not concepts::AccessibleImage<archetypes::IndexableImage>);
static_assert(concepts::AccessibleImage<archetypes::AccessibleImage>);
static_assert(not concepts::AccessibleImage<archetypes::BidirectionalImage>);
static_assert(concepts::AccessibleImage<archetypes::RawImage>);
}
TEST(Core, Concept_BidirectionalImage)
{
static_assert(not concepts::BidirectionalImage<archetypes::Image>);
static_assert(not concepts::BidirectionalImage<archetypes::ForwardImage>);
static_assert(not concepts::BidirectionalImage<archetypes::InputImage>);
static_assert(not concepts::BidirectionalImage<archetypes::IndexableImage>);
static_assert(not concepts::BidirectionalImage<archetypes::AccessibleImage>);
static_assert(concepts::BidirectionalImage<archetypes::BidirectionalImage>);
static_assert(concepts::BidirectionalImage<archetypes::RawImage>);
}
TEST(Core, Concept_RawImage)
{
static_assert(not concepts::RawImage<archetypes::Image>);
static_assert(not concepts::RawImage<archetypes::ForwardImage>);
static_assert(not concepts::RawImage<archetypes::InputImage>);
static_assert(not concepts::RawImage<archetypes::IndexableImage>);
static_assert(not concepts::RawImage<archetypes::AccessibleImage>);
static_assert(not concepts::RawImage<archetypes::BidirectionalImage>);
static_assert(concepts::RawImage<archetypes::RawImage>);
}
TEST(Core, Concept_ExtendedImage)
{
static_assert(not concepts::ExtendedImage<archetypes::Image>);
static_assert(not concepts::ExtendedImage<archetypes::ForwardImage>);
static_assert(not concepts::ExtendedImage<archetypes::InputImage>);
static_assert(not concepts::ExtendedImage<archetypes::IndexableImage>);
static_assert(not concepts::ExtendedImage<archetypes::AccessibleImage>);
static_assert(not concepts::ExtendedImage<archetypes::BidirectionalImage>);
static_assert(not concepts::ExtendedImage<archetypes::RawImage>);
static_assert(concepts::ExtendedImage<archetypes::ExtendedImage>);
}
TEST(Core, Concept_OutputImage) // ForwardImage, InputImage
{
static_assert(concepts::Image<archetypes::Image> && not concepts::OutputImage<archetypes::Image>);
static_assert(concepts::Image<archetypes::ForwardImage> && not concepts::OutputImage<archetypes::ForwardImage>);
static_assert(concepts::Image<archetypes::InputImage> && not concepts::OutputImage<archetypes::InputImage>);
static_assert(concepts::Image<archetypes::IndexableImage> && not concepts::OutputImage<archetypes::IndexableImage>);
static_assert(concepts::Image<archetypes::AccessibleImage> && not concepts::OutputImage<archetypes::AccessibleImage>);
static_assert(concepts::Image<archetypes::BidirectionalImage> &&
not concepts::OutputImage<archetypes::BidirectionalImage>);
static_assert(concepts::Image<archetypes::RawImage> && not concepts::OutputImage<archetypes::RawImage>);
static_assert(concepts::Image<archetypes::OutputImage> && concepts::OutputImage<archetypes::OutputImage>);
static_assert(concepts::Image<archetypes::OutputForwardImage> &&
concepts::OutputImage<archetypes::OutputForwardImage>);
static_assert(concepts::Image<archetypes::OutputIndexableImage> &&
concepts::OutputImage<archetypes::OutputIndexableImage>);
static_assert(concepts::Image<archetypes::OutputAccessibleImage> &&
concepts::OutputImage<archetypes::OutputAccessibleImage>);
static_assert(concepts::Image<archetypes::OutputBidirectionalImage> &&
concepts::OutputImage<archetypes::OutputBidirectionalImage>);
static_assert(concepts::Image<archetypes::OutputRawImage> && concepts::OutputImage<archetypes::OutputRawImage>);
}
TEST(Core, Concept_OutputIndexableImage)
{
static_assert(not concepts::IndexableImage<archetypes::Image> && not concepts::OutputImage<archetypes::Image>);
static_assert(not concepts::IndexableImage<archetypes::ForwardImage> &&
not concepts::OutputImage<archetypes::ForwardImage>);
static_assert(not concepts::IndexableImage<archetypes::InputImage> &&
not concepts::OutputImage<archetypes::InputImage>);
static_assert(concepts::IndexableImage<archetypes::IndexableImage> &&
not concepts::OutputImage<archetypes::IndexableImage>);
static_assert(not concepts::IndexableImage<archetypes::AccessibleImage> &&
not concepts::OutputImage<archetypes::AccessibleImage>);
static_assert(not concepts::IndexableImage<archetypes::BidirectionalImage> &&
not concepts::OutputImage<archetypes::BidirectionalImage>);
static_assert(concepts::IndexableImage<archetypes::RawImage> && not concepts::OutputImage<archetypes::RawImage>);
static_assert(not concepts::IndexableImage<archetypes::OutputImage> &&
concepts::OutputImage<archetypes::OutputImage>);
static_assert(not concepts::IndexableImage<archetypes::OutputForwardImage> &&
concepts::OutputImage<archetypes::OutputForwardImage>);
static_assert(concepts::IndexableImage<archetypes::OutputIndexableImage> &&
concepts::OutputImage<archetypes::OutputIndexableImage>);
static_assert(not concepts::IndexableImage<archetypes::OutputAccessibleImage> &&
concepts::OutputImage<archetypes::OutputAccessibleImage>);
static_assert(not concepts::IndexableImage<archetypes::OutputBidirectionalImage> &&
concepts::OutputImage<archetypes::OutputBidirectionalImage>);
static_assert(concepts::IndexableImage<archetypes::OutputRawImage> &&
concepts::OutputImage<archetypes::OutputRawImage>);
}
TEST(Core, Concept_OutputAccessibleImage)
{
static_assert(not concepts::AccessibleImage<archetypes::Image> && not concepts::OutputImage<archetypes::Image>);
static_assert(not concepts::AccessibleImage<archetypes::ForwardImage> &&
not concepts::OutputImage<archetypes::ForwardImage>);
static_assert(not concepts::AccessibleImage<archetypes::InputImage> &&
not concepts::OutputImage<archetypes::InputImage>);
static_assert(not concepts::AccessibleImage<archetypes::IndexableImage> &&
not concepts::OutputImage<archetypes::IndexableImage>);
static_assert(concepts::AccessibleImage<archetypes::AccessibleImage> &&
not concepts::OutputImage<archetypes::AccessibleImage>);
static_assert(not concepts::AccessibleImage<archetypes::BidirectionalImage> &&
not concepts::OutputImage<archetypes::BidirectionalImage>);
static_assert(concepts::AccessibleImage<archetypes::RawImage> && not concepts::OutputImage<archetypes::RawImage>);
static_assert(not concepts::AccessibleImage<archetypes::OutputImage> &&
concepts::OutputImage<archetypes::OutputImage>);
static_assert(not concepts::AccessibleImage<archetypes::OutputForwardImage> &&
concepts::OutputImage<archetypes::OutputForwardImage>);
static_assert(not concepts::AccessibleImage<archetypes::OutputIndexableImage> &&
concepts::OutputImage<archetypes::OutputIndexableImage>);
static_assert(concepts::AccessibleImage<archetypes::OutputAccessibleImage> &&
concepts::OutputImage<archetypes::OutputAccessibleImage>);
static_assert(not concepts::AccessibleImage<archetypes::OutputBidirectionalImage> &&
concepts::OutputImage<archetypes::OutputBidirectionalImage>);
static_assert(concepts::AccessibleImage<archetypes::OutputRawImage> &&
concepts::OutputImage<archetypes::OutputRawImage>);
}
TEST(Core, Concept_OutputBidirectionalImage)
{
static_assert(not concepts::BidirectionalImage<archetypes::Image> && not concepts::OutputImage<archetypes::Image>);
static_assert(not concepts::BidirectionalImage<archetypes::ForwardImage> &&
not concepts::OutputImage<archetypes::ForwardImage>);
static_assert(not concepts::BidirectionalImage<archetypes::InputImage> &&
not concepts::OutputImage<archetypes::InputImage>);
static_assert(not concepts::BidirectionalImage<archetypes::IndexableImage> &&
not concepts::OutputImage<archetypes::IndexableImage>);
static_assert(not concepts::BidirectionalImage<archetypes::AccessibleImage> &&
not concepts::OutputImage<archetypes::AccessibleImage>);
static_assert(concepts::BidirectionalImage<archetypes::BidirectionalImage> &&
not concepts::OutputImage<archetypes::BidirectionalImage>);
static_assert(concepts::BidirectionalImage<archetypes::RawImage> && not concepts::OutputImage<archetypes::RawImage>);
static_assert(not concepts::BidirectionalImage<archetypes::OutputImage> &&
concepts::OutputImage<archetypes::OutputImage>);
static_assert(not concepts::BidirectionalImage<archetypes::OutputForwardImage> &&
concepts::OutputImage<archetypes::OutputForwardImage>);
static_assert(not concepts::BidirectionalImage<archetypes::OutputIndexableImage> &&
concepts::OutputImage<archetypes::OutputIndexableImage>);
static_assert(not concepts::BidirectionalImage<archetypes::OutputAccessibleImage> &&
concepts::OutputImage<archetypes::OutputAccessibleImage>);
static_assert(concepts::BidirectionalImage<archetypes::OutputBidirectionalImage> &&
concepts::OutputImage<archetypes::OutputBidirectionalImage>);
static_assert(concepts::BidirectionalImage<archetypes::OutputRawImage> &&
concepts::OutputImage<archetypes::OutputRawImage>);
}
TEST(Core, Concept_OutputRawImage)
{
static_assert(not concepts::RawImage<archetypes::Image> && not concepts::OutputImage<archetypes::Image>);
static_assert(not concepts::RawImage<archetypes::ForwardImage> &&
not concepts::OutputImage<archetypes::ForwardImage>);
static_assert(not concepts::RawImage<archetypes::InputImage> && not concepts::OutputImage<archetypes::InputImage>);
static_assert(not concepts::RawImage<archetypes::IndexableImage> &&
not concepts::OutputImage<archetypes::IndexableImage>);
static_assert(not concepts::RawImage<archetypes::AccessibleImage> &&
not concepts::OutputImage<archetypes::AccessibleImage>);
static_assert(not concepts::RawImage<archetypes::BidirectionalImage> &&
not concepts::OutputImage<archetypes::BidirectionalImage>);
static_assert(concepts::RawImage<archetypes::RawImage> && not concepts::OutputImage<archetypes::RawImage>);
static_assert(not concepts::RawImage<archetypes::OutputImage> && concepts::OutputImage<archetypes::OutputImage>);
static_assert(not concepts::RawImage<archetypes::OutputForwardImage> &&
concepts::OutputImage<archetypes::OutputForwardImage>);
static_assert(not concepts::RawImage<archetypes::OutputIndexableImage> &&
concepts::OutputImage<archetypes::OutputIndexableImage>);
static_assert(not concepts::RawImage<archetypes::OutputAccessibleImage> &&
concepts::OutputImage<archetypes::OutputAccessibleImage>);
static_assert(not concepts::RawImage<archetypes::OutputBidirectionalImage> &&
concepts::OutputImage<archetypes::OutputBidirectionalImage>);
static_assert(concepts::RawImage<archetypes::OutputRawImage> && concepts::OutputImage<archetypes::OutputRawImage>);
}
#include <mln/core/concept/new/archetype/index.hpp>
#include <mln/core/concept/new/indexes.hpp>
#include <gtest/gtest.h>
namespace concepts = mln::concepts;
namespace concepts = mln::concepts;
namespace archetypes = mln::archetypes;
struct A
{
......@@ -19,4 +21,5 @@ TEST(Core, Concept_Index)
static_assert(!concepts::Index<double>);
static_assert(!concepts::Index<A>);
static_assert(!concepts::Index<B>);
static_assert(concepts::Index<archetypes::Index>);
}
#include <mln/core/concept/new/archetype/point.hpp>
#include <mln/core/concept/new/points.hpp>
#include <gtest/gtest.h>
namespace concepts = mln::concepts;
namespace concepts = mln::concepts;
namespace archetypes = mln::archetypes;
struct A
{
};
struct B
{
};
bool operator==(const B&, const B&)
{
return true;
}
bool operator!=(const B&, const B&)
{
return false;
}
struct C : B
{
};
bool operator<(const C&, const C&)
{
return true;
}
bool operator>(const C&, const C&)
{
return true;
}
bool operator<=(const C&, const C&)
{
return true;
}
bool operator>=(const C&, const C&)
{
return true;
}
TEST(Core, Concept_Point)
{
static_assert(concepts::Point<int>);
static_assert(concepts::Point<double>);
static_assert(!concepts::Point<A>);
static_assert(!concepts::Point<B>);
static_assert(concepts::Point<C>);
static_assert(concepts::Point<archetypes::Point>);
}
#include <mln/core/concept/new/archetype/range.hpp>
#include <mln/core/concept/new/ranges.hpp>
#include <gtest/gtest.h>
namespace concepts = mln::concepts;