union.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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/assert.hpp>
  5. #include <boost/hana/equal.hpp>
  6. #include <boost/hana/set.hpp>
  7. #include <boost/hana/union.hpp>
  8. #include <laws/base.hpp>
  9. namespace hana = boost::hana;
  10. using hana::test::ct_eq;
  11. int main() {
  12. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  13. hana::union_(
  14. hana::make_set(),
  15. hana::make_set()
  16. ),
  17. hana::make_set()
  18. ));
  19. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  20. hana::union_(
  21. hana::make_set(ct_eq<0>{}),
  22. hana::make_set()
  23. ),
  24. hana::make_set(ct_eq<0>{})
  25. ));
  26. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  27. hana::union_(
  28. hana::make_set(),
  29. hana::make_set(ct_eq<0>{})
  30. ),
  31. hana::make_set(ct_eq<0>{})
  32. ));
  33. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  34. hana::union_(
  35. hana::make_set(ct_eq<0>{}),
  36. hana::make_set(ct_eq<0>{})
  37. ),
  38. hana::make_set(ct_eq<0>{})
  39. ));
  40. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  41. hana::union_(
  42. hana::make_set(ct_eq<0>{}),
  43. hana::make_set(ct_eq<1>{})
  44. ),
  45. hana::make_set(ct_eq<0>{}, ct_eq<1>{})
  46. ));
  47. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  48. hana::union_(
  49. hana::make_set(ct_eq<0>{}, ct_eq<1>{}),
  50. hana::make_set(ct_eq<1>{})
  51. ),
  52. hana::make_set(ct_eq<0>{}, ct_eq<1>{})
  53. ));
  54. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  55. hana::union_(
  56. hana::make_set(ct_eq<0>{}),
  57. hana::make_set(ct_eq<1>{}, ct_eq<0>{})
  58. ),
  59. hana::make_set(ct_eq<0>{}, ct_eq<1>{})
  60. ));
  61. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  62. hana::union_(
  63. hana::make_set(ct_eq<0>{}, ct_eq<2>{}),
  64. hana::make_set(ct_eq<1>{})
  65. ),
  66. hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})
  67. ));
  68. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  69. hana::union_(
  70. hana::make_set(ct_eq<0>{}, ct_eq<2>{}, ct_eq<5>{}),
  71. hana::make_set(ct_eq<1>{}, ct_eq<3>{}, ct_eq<4>{})
  72. ),
  73. hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{})
  74. ));
  75. }