utility_axis.hpp 884 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2018-2019 Hans Dembinski
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt
  5. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_HISTOGRAM_TEST_UTILITY_AXIS_HPP
  7. #define BOOST_HISTOGRAM_TEST_UTILITY_AXIS_HPP
  8. #include <boost/core/lightweight_test.hpp>
  9. #include <boost/histogram/fwd.hpp>
  10. namespace boost {
  11. namespace histogram {
  12. template <typename Axis>
  13. void test_axis_iterator(const Axis& a, int begin, int end) {
  14. for (auto bin : a) {
  15. BOOST_TEST_EQ(bin, a.bin(begin));
  16. ++begin;
  17. }
  18. BOOST_TEST_EQ(begin, end);
  19. auto rit = a.rbegin();
  20. for (; rit != a.rend(); ++rit) {
  21. --begin;
  22. BOOST_TEST_EQ(*rit, a.bin(begin));
  23. }
  24. }
  25. namespace axis {
  26. bool operator==(const null_type&, const null_type&) { return true; }
  27. } // namespace axis
  28. } // namespace histogram
  29. } // namespace boost
  30. #endif