algorithm_channel_relation.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // Copyright 2005-2007 Adobe Systems Incorporated
  3. // Copyright 2018 Mateusz Loskot <mateusz at loskot dot net>
  4. //
  5. // Distributed under the Boost Software License, Version 1.0
  6. // See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt
  8. //
  9. #include <boost/gil/channel_algorithm.hpp>
  10. #define BOOST_TEST_MODULE test_algorithm_channel_relation
  11. #include "unit_test.hpp"
  12. #include "test_fixture.hpp"
  13. namespace gil = boost::gil;
  14. namespace fixture = boost::gil::test::fixture;
  15. template <typename ChannelFixtureBase>
  16. void test_channel_relation()
  17. {
  18. using fixture_t = fixture::channel<ChannelFixtureBase>;
  19. using channel_value_t = typename fixture_t::channel_value_t;
  20. channel_value_t const one = 1;
  21. fixture_t f;
  22. BOOST_TEST(f.min_v_ <= f.max_v_);
  23. BOOST_TEST(f.max_v_ >= f.min_v_);
  24. BOOST_TEST(f.min_v_ < f.max_v_);
  25. BOOST_TEST(f.max_v_ > f.min_v_);
  26. BOOST_TEST(f.max_v_ != f.min_v_);
  27. BOOST_TEST(f.min_v_ == f.min_v_);
  28. BOOST_TEST(f.min_v_ != one); // comparable to integral
  29. }
  30. BOOST_AUTO_TEST_CASE_TEMPLATE(channel_value, Channel, fixture::channel_byte_types)
  31. {
  32. using fixture_t = fixture::channel_value<Channel>;
  33. test_channel_relation<fixture_t>();
  34. }
  35. BOOST_AUTO_TEST_CASE_TEMPLATE(channel_reference, Channel, fixture::channel_byte_types)
  36. {
  37. using fixture_t = fixture::channel_reference<Channel&>;
  38. test_channel_relation<fixture_t>();
  39. }
  40. BOOST_AUTO_TEST_CASE_TEMPLATE(channel_reference_const, Channel, fixture::channel_byte_types)
  41. {
  42. using fixture_t = fixture::channel_reference<Channel const&>;
  43. test_channel_relation<fixture_t>();
  44. }
  45. BOOST_AUTO_TEST_CASE_TEMPLATE(packed_channel_reference, BitField, fixture::channel_bitfield_types)
  46. {
  47. using channels565_t = fixture::packed_channels565<BitField>;
  48. test_channel_relation<typename channels565_t::fixture_0_5_t>();
  49. test_channel_relation<typename channels565_t::fixture_5_6_t >();
  50. test_channel_relation<typename channels565_t::fixture_11_5_t>();
  51. }
  52. BOOST_AUTO_TEST_CASE_TEMPLATE(packed_dynamic_channel_reference, BitField, fixture::channel_bitfield_types)
  53. {
  54. using channels565_t = fixture::packed_dynamic_channels565<BitField>;
  55. test_channel_relation<typename channels565_t::fixture_5_t>();
  56. test_channel_relation<typename channels565_t::fixture_6_t>();
  57. }