diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a691f618d..8d3711697 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,13 +7,15 @@ # message(STATUS "Boost.GIL: Configuring core tests") +# All-in-one tests, legacy +# TODO: To be refactored to modular foreach(_name channel image pixel pixel_iterator promote_integral) - set(_target test_core_${_name}) + set(_target all_in_one_${_name}) add_executable(${_target} "") target_sources(${_target} PRIVATE ${_name}.cpp error_if.cpp) @@ -23,26 +25,29 @@ foreach(_name gil_include_directories gil_dependencies) target_compile_definitions(${_target} PRIVATE BOOST_GIL_USE_CONCEPT_CHECK) - add_test(test.core.${_name} ${_target}) + add_test(test.all_in_one.${_name} ${_target}) unset(_target) unset(_name) endforeach() # Add extra source files accompanying image.cpp -target_sources(test_core_image +target_sources(all_in_one_image PRIVATE error_if.cpp sample_image.cpp) -add_test(test.core.image - test_core_image +add_test(test.all_in_one.image + all_in_one_image ${CMAKE_CURRENT_SOURCE_DIR}/gil_reference_checksums.txt) if(GIL_BUILD_HEADERS_TESTS) add_subdirectory(headers) endif() -add_subdirectory(algorithm) -add_subdirectory(channel) -add_subdirectory(image_view) +# Modular tests add_subdirectory(point) +add_subdirectory(channel) +add_subdirectory(pixel) +add_subdirectory(image) +add_subdirectory(image_view) +add_subdirectory(algorithm) diff --git a/test/algorithm/CMakeLists.txt b/test/algorithm/CMakeLists.txt index df957591a..09a5abb7a 100644 --- a/test/algorithm/CMakeLists.txt +++ b/test/algorithm/CMakeLists.txt @@ -8,7 +8,7 @@ foreach(_name for_each_pixel std_fill) - set(_target test_core_${_name}) + set(_target test_core_algorithm_${_name}) add_executable(${_target} "") target_sources(${_target} PRIVATE ${_name}.cpp) diff --git a/test/image/CMakeLists.txt b/test/image/CMakeLists.txt new file mode 100644 index 000000000..e660b689c --- /dev/null +++ b/test/image/CMakeLists.txt @@ -0,0 +1,23 @@ +# +# Copyright (c) 2019 Mateusz Loskot +# +# 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) +# +foreach(_name + concepts) + set(_target test_core_image_${_name}) + + add_executable(${_target} "") + target_sources(${_target} PRIVATE ${_name}.cpp) + target_link_libraries(${_target} + PRIVATE + gil_compile_options + gil_include_directories + gil_dependencies) + add_test(test.core.${_name} ${_target}) + + unset(_name) + unset(_target) +endforeach() diff --git a/test/image/Jamfile b/test/image/Jamfile new file mode 100644 index 000000000..9ed002776 --- /dev/null +++ b/test/image/Jamfile @@ -0,0 +1,17 @@ +# Boost.GIL (Generic Image Library) - tests +# +# Copyright (c) 2019 Mateusz Loskot +# +# 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) + +import testing ; + +project + : requirements + $(BOOST_ROOT) + .. + ; + +compile concepts.cpp ; diff --git a/test/image/concepts.cpp b/test/image/concepts.cpp new file mode 100644 index 000000000..1565feb9d --- /dev/null +++ b/test/image/concepts.cpp @@ -0,0 +1,23 @@ +// +// Copyright 2019 Mateusz Loskot +// +// 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 + +#include + +#include + +namespace gil = boost::gil; +using boost::function_requires; + +int main() +{ + function_requires>(); + function_requires>(); + + return 0; +} diff --git a/test/image_view/CMakeLists.txt b/test/image_view/CMakeLists.txt index b61efe01d..cda185732 100644 --- a/test/image_view/CMakeLists.txt +++ b/test/image_view/CMakeLists.txt @@ -7,8 +7,15 @@ # foreach(_name collection - image_view_concepts) - set(_target test_core_${_name}) + concepts + derived_view_type + is_planar + view_is_basic + view_is_mutable + view_is_step + view_type + view_type_from_pixel) + set(_target test_core_image_view_${_name}) add_executable(${_target} "") target_sources(${_target} PRIVATE ${_name}.cpp) diff --git a/test/image_view/Jamfile b/test/image_view/Jamfile index 7b77f0400..fad67b4b5 100644 --- a/test/image_view/Jamfile +++ b/test/image_view/Jamfile @@ -14,5 +14,13 @@ project .. ; -compile image_view_concepts.cpp ; +compile concepts.cpp ; +compile derived_view_type.cpp ; +compile is_planar.cpp ; +compile view_is_basic.cpp ; +compile view_is_mutable.cpp ; +compile view_is_step.cpp ; +compile view_type.cpp ; +compile view_type_from_pixel.cpp ; + run collection.cpp ; diff --git a/test/image_view/concepts.cpp b/test/image_view/concepts.cpp new file mode 100644 index 000000000..34ed7e067 --- /dev/null +++ b/test/image_view/concepts.cpp @@ -0,0 +1,89 @@ +// +// Copyright 2018 Mateusz Loskot +// +// 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 +// +// FIXME: There are missing headers internally, leading to incomplete types +#if 0 +#include +#include +#include +#else +#include +#endif + +namespace gil = boost::gil; + +template +void test_view() +{ + boost::function_requires>(); + boost::function_requires>(); + boost::function_requires>(); + boost::function_requires>(); +} + +template +void test_view_planar() +{ + boost::function_requires>(); + boost::function_requires>(); +} + +int main() +{ + test_view(); + test_view(); + + test_view(); + test_view(); + test_view(); + test_view(); + + test_view(); + test_view(); + test_view(); + test_view(); + + test_view(); + test_view(); + test_view(); + test_view(); + + test_view(); + test_view(); + test_view(); + test_view(); + + test_view(); + test_view(); + test_view(); + test_view(); + test_view_planar(); + test_view_planar(); + test_view_planar(); + test_view_planar(); + + test_view(); + test_view(); + test_view(); + test_view(); + test_view_planar(); + test_view_planar(); + test_view_planar(); + test_view_planar(); + + test_view(); + test_view(); + test_view(); + test_view(); + + test_view_planar(); + test_view_planar(); + test_view_planar(); + test_view_planar(); + + return 0; +} diff --git a/test/image_view/derived_view_type.cpp b/test/image_view/derived_view_type.cpp new file mode 100644 index 000000000..805cf31eb --- /dev/null +++ b/test/image_view/derived_view_type.cpp @@ -0,0 +1,45 @@ +// +// Copyright 2018 Mateusz Loskot +// +// 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 + +#include + +namespace gil = boost::gil; + +int main() +{ + + static_assert(std::is_same + < + gil::derived_view_type::type, + gil::cmyk8c_planar_step_view_t + >::value, "derived_view_type should be cmyk8c_planar_step_view_t"); + + static_assert(std::is_same + < + gil::derived_view_type + < + gil::cmyk8c_planar_step_view_t, std::uint16_t, gil::rgb_layout_t + >::type, + gil::rgb16c_planar_step_view_t + >::value, "derived_view_type should be rgb16c_planar_step_view_t"); + + static_assert(std::is_same + < + gil::derived_view_type + < + gil::cmyk8c_planar_step_view_t, + boost::use_default, + gil::rgb_layout_t, + std::false_type, + boost::use_default, + std::false_type + >::type, + gil::rgb8c_step_view_t + >::value, "derived_view_type should be rgb8c_step_view_t"); +} diff --git a/test/image_view/image_view_concepts.cpp b/test/image_view/image_view_concepts.cpp deleted file mode 100644 index 67987ff53..000000000 --- a/test/image_view/image_view_concepts.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -// Copyright 2018 Mateusz Loskot -// -// 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 -#include -#include - -namespace gil = boost::gil; - -int main() -{ - boost::function_requires>(); - - boost::function_requires>(); - boost::function_requires>(); - boost::function_requires>(); - - return 0; -} diff --git a/test/image_view/is_planar.cpp b/test/image_view/is_planar.cpp new file mode 100644 index 000000000..d580c2e8d --- /dev/null +++ b/test/image_view/is_planar.cpp @@ -0,0 +1,77 @@ +// +// Copyright 2018 Mateusz Loskot +// +// 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 + +namespace gil = boost::gil; + +template +void test_is_planar() +{ + static_assert(gil::is_planar::value, "view should be planar"); +} + +template +void test_is_planar_not() +{ + static_assert(!gil::is_planar::value, "view should not be planar"); +} + + +int main() +{ + test_is_planar_not(); + test_is_planar_not(); + + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + test_is_planar(); + test_is_planar(); + test_is_planar(); + test_is_planar(); + + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + test_is_planar(); + test_is_planar(); + test_is_planar(); + test_is_planar(); + + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + test_is_planar_not(); + + test_is_planar(); + test_is_planar(); + test_is_planar(); + test_is_planar(); +} diff --git a/test/image_view/view_is_basic.cpp b/test/image_view/view_is_basic.cpp new file mode 100644 index 000000000..d40ea658f --- /dev/null +++ b/test/image_view/view_is_basic.cpp @@ -0,0 +1,76 @@ +// +// Copyright 2018 Mateusz Loskot +// +// 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 + +namespace gil = boost::gil; + +template +void test_view_is_basic() +{ + static_assert(gil::view_is_basic::value, "view should be basic"); +} + +template +void test_view_is_basic_not() +{ + static_assert(!gil::view_is_basic::value, "view should not be basic"); +} + +int main() +{ + test_view_is_basic(); + test_view_is_basic(); + + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); + test_view_is_basic(); +} diff --git a/test/image_view/view_is_mutable.cpp b/test/image_view/view_is_mutable.cpp new file mode 100644 index 000000000..70f91d9c1 --- /dev/null +++ b/test/image_view/view_is_mutable.cpp @@ -0,0 +1,76 @@ +// +// Copyright 2018 Mateusz Loskot +// +// 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 + +namespace gil = boost::gil; + +template +void test_view_is_mutable() +{ + static_assert(gil::view_is_mutable::value, "view should be mutable"); +} + +template +void test_view_is_mutable_not() +{ + static_assert(!gil::view_is_mutable::value, "view should not be mutable"); +} + +int main() +{ + test_view_is_mutable(); + test_view_is_mutable_not(); + + test_view_is_mutable(); + test_view_is_mutable(); + test_view_is_mutable_not(); + test_view_is_mutable_not(); + + test_view_is_mutable(); + test_view_is_mutable(); + test_view_is_mutable_not(); + test_view_is_mutable_not(); + + test_view_is_mutable(); + test_view_is_mutable(); + test_view_is_mutable_not(); + test_view_is_mutable_not(); + + test_view_is_mutable(); + test_view_is_mutable(); + test_view_is_mutable_not(); + test_view_is_mutable_not(); + + test_view_is_mutable(); + test_view_is_mutable(); + test_view_is_mutable(); + test_view_is_mutable(); + test_view_is_mutable_not(); + test_view_is_mutable_not(); + test_view_is_mutable_not(); + test_view_is_mutable_not(); + + test_view_is_mutable(); + test_view_is_mutable(); + test_view_is_mutable(); + test_view_is_mutable(); + test_view_is_mutable_not(); + test_view_is_mutable_not(); + test_view_is_mutable_not(); + test_view_is_mutable_not(); + + test_view_is_mutable(); + test_view_is_mutable(); + test_view_is_mutable_not(); + test_view_is_mutable_not(); + + test_view_is_mutable(); + test_view_is_mutable(); + test_view_is_mutable_not(); + test_view_is_mutable_not(); +} diff --git a/test/image_view/view_is_step.cpp b/test/image_view/view_is_step.cpp new file mode 100644 index 000000000..917bc9dd5 --- /dev/null +++ b/test/image_view/view_is_step.cpp @@ -0,0 +1,57 @@ +// +// Copyright 2018 Mateusz Loskot +// +// 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 + +namespace gil = boost::gil; + +template +void test_view_is_step_in_xy() +{ + static_assert(gil::view_is_step_in_x::value, "view should support horizontal step"); + static_assert(gil::view_is_step_in_y::value, "view should support vertical step"); +} + +template +void test_view_is_step_in_y() +{ + static_assert(gil::view_is_step_in_y::value, "view should support vertical step"); +} + +template +void test_view_is_step_in_x_not() +{ + static_assert(!gil::view_is_step_in_x::value, "view should not support horizontal step"); +} + +int main() +{ + test_view_is_step_in_xy(); + test_view_is_step_in_xy(); + test_view_is_step_in_xy(); + test_view_is_step_in_xy(); + test_view_is_step_in_xy(); + test_view_is_step_in_xy(); + test_view_is_step_in_xy(); + test_view_is_step_in_xy(); + test_view_is_step_in_xy(); + test_view_is_step_in_xy(); + + test_view_is_step_in_y(); + test_view_is_step_in_y(); + test_view_is_step_in_y(); + test_view_is_step_in_y(); + test_view_is_step_in_y(); + test_view_is_step_in_y(); + + test_view_is_step_in_x_not(); + test_view_is_step_in_x_not(); + test_view_is_step_in_x_not(); + test_view_is_step_in_x_not(); + test_view_is_step_in_x_not(); + test_view_is_step_in_x_not(); +} diff --git a/test/image_view/view_type.cpp b/test/image_view/view_type.cpp new file mode 100644 index 000000000..11033f489 --- /dev/null +++ b/test/image_view/view_type.cpp @@ -0,0 +1,114 @@ +// +// Copyright 2018 Mateusz Loskot +// +// 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 + +#include + +namespace gil = boost::gil; + +struct Interleaved : std::false_type {}; +struct Planar : std::true_type {}; +struct NotStepX : std::false_type {}; +struct StepX : std::true_type {}; +struct Immutable : std::false_type {}; +struct Mutable : std::true_type {}; + +template +void test() +{ + static_assert(std::is_same + < + typename gil::view_type + < + std::uint8_t, + Layout, + IsPlanar::value, + IsStepX::value, + IsMutable::value + >::type, + ResultView + >::value, "view_type yields unexpected view"); +} + +template +void test_not() +{ + static_assert(!std::is_same + < + typename gil::view_type + < + std::uint8_t, + Layout, + IsPlanar::value, + IsStepX::value, + IsMutable::value + >::type, + ResultView + >::value, "view_type yields unexpected view"); +} + +int main() +{ + test(); + test(); + test(); + test(); + test_not(); + test_not(); + test_not(); + test_not(); + + test(); + test(); + test(); + test(); + test_not(); + test_not(); + + test(); + test(); + test(); + test(); + + test(); + test(); + test(); + test(); + test_not(); + + test(); + test(); + test(); + test(); + test_not(); + test_not(); + + test(); + test(); + test(); + test(); + test_not(); + test_not(); + test_not(); + + test(); + test(); + test(); + test(); + + test(); + test(); + test(); + test(); + test_not(); + + test(); + test(); + test(); + test(); +} diff --git a/test/image_view/view_type_from_pixel.cpp b/test/image_view/view_type_from_pixel.cpp new file mode 100644 index 000000000..b1e1d279a --- /dev/null +++ b/test/image_view/view_type_from_pixel.cpp @@ -0,0 +1,119 @@ +// +// Copyright 2018 Mateusz Loskot +// +// 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 + +#include + +namespace gil = boost::gil; + +struct Interleaved : std::false_type {}; +struct Planar : std::true_type {}; +struct NotStepX : std::false_type {}; +struct StepX : std::true_type {}; +struct Immutable : std::false_type {}; +struct Mutable : std::true_type {}; + +template +void test() +{ + static_assert(std::is_same + < + typename gil::view_type_from_pixel + < + Pixel, + IsPlanar::value, + IsStepX::value, + IsMutable::value + >::type, + ResultView + >::value, "view_type_from_pixel yields unexpected view"); +} + +template +void test_not() +{ + static_assert(!std::is_same + < + typename gil::view_type_from_pixel + < + Pixel, + IsPlanar::value, + IsStepX::value, + IsMutable::value + >::type, + ResultView + >::value, "view_type_from_pixel yields unexpected view"); +} + +int main() +{ + test(); + test(); + // Immutable view from mutable pixel type is allowed + test(); + // Mutable view from immutable pixel type not allowed + test_not(); + + test(); + test_not(); + test(); + test_not(); + test_not(); + test_not(); + test_not(); + + test(); + test(); + test(); + test(); + test_not(); + test_not(); + + test(); + test(); + test(); + test(); + + test(); + test(); + test(); + test(); + test_not(); + + test(); + test(); + test(); + test(); + test_not(); + test_not(); + + test(); + test(); + test(); + test(); + test_not(); + test_not(); + test_not(); + test_not(); + + test(); + test(); + test(); + test(); + + test(); + test(); + test(); + test(); + test_not(); + + test(); + test(); + test(); + test(); +} diff --git a/test/pixel/CMakeLists.txt b/test/pixel/CMakeLists.txt new file mode 100644 index 000000000..5b00949ba --- /dev/null +++ b/test/pixel/CMakeLists.txt @@ -0,0 +1,23 @@ +# +# Copyright (c) 2019 Mateusz Loskot +# +# 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) +# +foreach(_name + concepts) + set(_target test_core_pixel_${_name}) + + add_executable(${_target} "") + target_sources(${_target} PRIVATE ${_name}.cpp) + target_link_libraries(${_target} + PRIVATE + gil_compile_options + gil_include_directories + gil_dependencies) + add_test(test.core.${_name} ${_target}) + + unset(_name) + unset(_target) +endforeach() diff --git a/test/pixel/Jamfile b/test/pixel/Jamfile new file mode 100644 index 000000000..9ed002776 --- /dev/null +++ b/test/pixel/Jamfile @@ -0,0 +1,17 @@ +# Boost.GIL (Generic Image Library) - tests +# +# Copyright (c) 2019 Mateusz Loskot +# +# 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) + +import testing ; + +project + : requirements + $(BOOST_ROOT) + .. + ; + +compile concepts.cpp ; diff --git a/test/pixel/concepts.cpp b/test/pixel/concepts.cpp new file mode 100644 index 000000000..a4df179bf --- /dev/null +++ b/test/pixel/concepts.cpp @@ -0,0 +1,43 @@ +// +// Copyright 2019 Mateusz Loskot +// +// 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 + +#include +#include + +namespace mpl = boost::mpl; +namespace gil = boost::gil; +using boost::function_requires; + +int main() +{ + function_requires>(); + function_requires>(); + function_requires>(); + + using rgb565_pixel_t = gil::packed_pixel_type + < + std::uint16_t, + mpl::vector3_c, + gil::rgb_layout_t + >::type; + function_requires>(); + function_requires>(); + + using bgr556_pixel_t = gil::packed_pixel_type + < + std::uint16_t, + mpl::vector3_c, + gil::bgr_layout_t>::type; + function_requires>(); + function_requires>(); + + function_requires>(); + + return 0; +} diff --git a/test/point/CMakeLists.txt b/test/point/CMakeLists.txt index d5b0b26a6..dc410b6ff 100644 --- a/test/point/CMakeLists.txt +++ b/test/point/CMakeLists.txt @@ -6,9 +6,9 @@ # http://www.boost.org/LICENSE_1_0.txt) # foreach(_name - point - point_concepts) - set(_target test_core_${_name}) + concepts + point) + set(_target test_core_point_${_name}) add_executable(${_target} "") target_sources(${_target} PRIVATE ${_name}.cpp) diff --git a/test/point/Jamfile b/test/point/Jamfile index 7185ddcae..a940ae34e 100644 --- a/test/point/Jamfile +++ b/test/point/Jamfile @@ -14,5 +14,5 @@ project .. ; -compile point_concepts.cpp ; +compile concepts.cpp ; run point.cpp ; diff --git a/test/point/point_concepts.cpp b/test/point/concepts.cpp similarity index 100% rename from test/point/point_concepts.cpp rename to test/point/concepts.cpp