test_fixture.hpp 924 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. #include <boost/gil.hpp>
  9. #include <boost/gil/extension/numeric/kernel.hpp>
  10. #include <boost/assert.hpp>
  11. #include <initializer_list>
  12. #include <type_traits>
  13. namespace boost { namespace gil {
  14. namespace test { namespace fixture {
  15. template <typename T>
  16. auto create_kernel(std::initializer_list<T> const& values)
  17. -> gil::kernel_1d<T>
  18. {
  19. static_assert(std::is_arithmetic<T>::value,
  20. "kernel value type should be integral or floating-point type");
  21. BOOST_ASSERT_MSG((values.size() - 1) % 2 == 0, "expected odd number of kernel values");
  22. gil::kernel_1d<T> kernel(values.begin(), values.size(), (values.size() - 1) / 2);
  23. return kernel;
  24. }
  25. }}}} // namespace boost::gil::test::fixture