drop_while.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #ifndef BOOST_HANA_TEST_AUTO_DROP_WHILE_HPP
  5. #define BOOST_HANA_TEST_AUTO_DROP_WHILE_HPP
  6. #include <boost/hana/assert.hpp>
  7. #include <boost/hana/bool.hpp>
  8. #include <boost/hana/drop_while.hpp>
  9. #include <boost/hana/equal.hpp>
  10. #include <boost/hana/functional/id.hpp>
  11. #include <boost/hana/not_equal.hpp>
  12. #include <laws/base.hpp>
  13. #include "test_case.hpp"
  14. TestCase test_drop_while{[]{
  15. namespace hana = boost::hana;
  16. using hana::test::ct_eq;
  17. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  18. hana::drop_while(MAKE_TUPLE(), hana::id),
  19. MAKE_TUPLE()
  20. ));
  21. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  22. hana::drop_while(MAKE_TUPLE(hana::true_c), hana::id),
  23. MAKE_TUPLE()
  24. ));
  25. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  26. hana::drop_while(MAKE_TUPLE(hana::false_c), hana::id),
  27. MAKE_TUPLE(hana::false_c)
  28. ));
  29. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  30. hana::drop_while(MAKE_TUPLE(hana::true_c, hana::true_c), hana::id),
  31. MAKE_TUPLE()
  32. ));
  33. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  34. hana::drop_while(MAKE_TUPLE(hana::true_c, hana::false_c), hana::id),
  35. MAKE_TUPLE(hana::false_c)
  36. ));
  37. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  38. hana::drop_while(MAKE_TUPLE(hana::false_c, hana::true_c), hana::id),
  39. MAKE_TUPLE(hana::false_c, hana::true_c)
  40. ));
  41. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  42. hana::drop_while(MAKE_TUPLE(hana::false_c, hana::false_c), hana::id),
  43. MAKE_TUPLE(hana::false_c, hana::false_c)
  44. ));
  45. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  46. hana::drop_while(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::not_equal.to(ct_eq<99>{})),
  47. MAKE_TUPLE()
  48. ));
  49. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  50. hana::drop_while(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::not_equal.to(ct_eq<1>{})),
  51. MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{})
  52. ));
  53. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  54. hana::drop_while(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::not_equal.to(ct_eq<3>{})),
  55. MAKE_TUPLE(ct_eq<3>{})
  56. ));
  57. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  58. hana::drop_while(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::not_equal.to(ct_eq<0>{})),
  59. MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})
  60. ));
  61. }};
  62. #endif // !BOOST_HANA_TEST_AUTO_DROP_WHILE_HPP