forked from boostorg/gil
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix any_image_view::const_t (boostorg#526)
Use inherited constructors in any_image as well
- Loading branch information
Showing
5 changed files
with
136 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// | ||
// Copyright 2020 Samuel Debionne | ||
// | ||
// 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.hpp> | ||
#include <boost/gil/extension/dynamic_image/any_image_view.hpp> | ||
|
||
#include <boost/core/lightweight_test.hpp> | ||
#include <boost/core/lightweight_test_trait.hpp> | ||
|
||
#include <type_traits> | ||
|
||
#include "test_fixture.hpp" | ||
#include "core/image/test_fixture.hpp" | ||
|
||
namespace gil = boost::gil; | ||
namespace fixture = boost::gil::test::fixture; | ||
|
||
void test_any_image_view_nested_types() | ||
{ | ||
BOOST_TEST_TRAIT_SAME(gil::any_image_view<gil::gray8_view_t>::const_t, gil::any_image_view<gil::gray8c_view_t>); | ||
} | ||
|
||
|
||
struct test_any_image_view_init_ctor | ||
{ | ||
template <typename Image> | ||
void operator()(Image const&) | ||
{ | ||
using image_t = Image; | ||
using view_t = typename Image::view_t; | ||
using any_view_t = gil::any_image_view<view_t>; | ||
using any_const_view_t = typename any_view_t::const_t; | ||
Image i0(fixture::create_image<image_t>(4, 4, 128)); | ||
|
||
view_t v0 = gil::view(i0); | ||
any_view_t v1 = v0; | ||
|
||
BOOST_TEST_EQ(v1.dimensions().x, 4); | ||
BOOST_TEST_EQ(v1.dimensions().y, 4); | ||
|
||
any_const_view_t v2 = v0; | ||
|
||
BOOST_TEST_EQ(v2.dimensions().x, 4); | ||
BOOST_TEST_EQ(v2.dimensions().y, 4); | ||
|
||
//any_const_view_t v3 = v1; | ||
} | ||
static void run() | ||
{ | ||
boost::mp11::mp_for_each<fixture::image_types>(test_any_image_view_init_ctor{}); | ||
} | ||
}; | ||
|
||
struct test_any_image_view_copy_ctor | ||
{ | ||
template <typename Image> | ||
void operator()(Image const&) | ||
{ | ||
using image_t = Image; | ||
using view_t = typename Image::view_t; | ||
using any_view_t = gil::any_image_view<view_t>; | ||
using any_const_view_t = typename any_view_t::const_t; | ||
Image i0(fixture::create_image<image_t>(4, 4, 128)); | ||
|
||
view_t v0 = gil::view(i0); | ||
any_view_t v1 = v0; | ||
|
||
BOOST_TEST_EQ(v1.dimensions().x, 4); | ||
BOOST_TEST_EQ(v1.dimensions().y, 4); | ||
|
||
any_const_view_t v2 = v0; | ||
|
||
BOOST_TEST_EQ(v2.dimensions().x, 4); | ||
BOOST_TEST_EQ(v2.dimensions().y, 4); | ||
|
||
//any_const_view_t v3 = v1; | ||
} | ||
static void run() | ||
{ | ||
boost::mp11::mp_for_each<fixture::image_types>(test_any_image_view_copy_ctor{}); | ||
} | ||
}; | ||
|
||
struct test_any_image_view_assign_operator | ||
{ | ||
template <typename Image> | ||
void operator()(Image const&) | ||
{ | ||
using image_t = Image; | ||
using view_t = typename Image::view_t; | ||
using any_view_t = gil::any_image_view<view_t>; | ||
using any_const_view_t = typename any_view_t::const_t; | ||
Image i0(fixture::create_image<image_t>(4, 4, 128)); | ||
|
||
view_t v0 = gil::view(i0); | ||
any_view_t v1; | ||
any_const_view_t v2; | ||
|
||
v1 = v0; | ||
|
||
BOOST_TEST_EQ(v1.dimensions().x, 4); | ||
BOOST_TEST_EQ(v1.dimensions().y, 4); | ||
|
||
v2 = v0; | ||
|
||
BOOST_TEST_EQ(v2.dimensions().x, 4); | ||
BOOST_TEST_EQ(v2.dimensions().y, 4); | ||
|
||
//v2 = v1; | ||
} | ||
static void run() | ||
{ | ||
boost::mp11::mp_for_each<fixture::image_types>(test_any_image_view_assign_operator{}); | ||
} | ||
}; | ||
|
||
int main() | ||
{ | ||
test_any_image_view_init_ctor::run(); | ||
test_any_image_view_copy_ctor::run(); | ||
test_any_image_view_assign_operator::run(); | ||
|
||
return ::boost::report_errors(); | ||
} |