laws.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright Louis Dionne 2013-2017
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  4. #include <boost/hana/map.hpp>
  5. #include <boost/hana/tuple.hpp>
  6. #include <laws/base.hpp>
  7. #include <laws/comparable.hpp>
  8. #include <laws/foldable.hpp>
  9. #include <laws/searchable.hpp>
  10. #include <support/minimal_product.hpp>
  11. namespace hana = boost::hana;
  12. template <int i>
  13. auto key() { return hana::test::ct_eq<i>{}; }
  14. template <int i>
  15. auto val() { return hana::test::ct_eq<-i>{}; }
  16. template <int i, int j>
  17. auto p() { return ::minimal_product(key<i>(), val<j>()); }
  18. int main() {
  19. auto maps = hana::make_tuple(
  20. hana::make_map(),
  21. hana::make_map(p<1, 1>()),
  22. hana::make_map(p<1, 2>()),
  23. hana::make_map(p<1, 1>(), p<2, 2>()),
  24. hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>())
  25. );
  26. hana::test::TestComparable<hana::map_tag>{maps};
  27. hana::test::TestSearchable<hana::map_tag>{maps, hana::make_tuple(key<1>(), key<4>())};
  28. hana::test::TestFoldable<hana::map_tag>{maps};
  29. }