• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
5 #ifndef BOOST_HANA_TEST_AUTO_TAKE_WHILE_HPP
6 #define BOOST_HANA_TEST_AUTO_TAKE_WHILE_HPP
7 
8 #include <boost/hana/assert.hpp>
9 #include <boost/hana/equal.hpp>
10 #include <boost/hana/not_equal.hpp>
11 #include <boost/hana/take_while.hpp>
12 
13 #include "test_case.hpp"
14 #include <laws/base.hpp>
15 
16 
__anonf4d654b60102null17 TestCase test_take_while{[]{
18     namespace hana = boost::hana;
19     using hana::test::ct_eq;
20 
21     auto z = ct_eq<999>{};
22 
23     BOOST_HANA_CONSTANT_CHECK(hana::equal(
24         hana::take_while(MAKE_TUPLE(), hana::not_equal.to(z)),
25         MAKE_TUPLE()
26     ));
27 
28     BOOST_HANA_CONSTANT_CHECK(hana::equal(
29         hana::take_while(MAKE_TUPLE(ct_eq<1>{}), hana::not_equal.to(z)),
30         MAKE_TUPLE(ct_eq<1>{})
31     ));
32     BOOST_HANA_CONSTANT_CHECK(hana::equal(
33         hana::take_while(MAKE_TUPLE(z), hana::not_equal.to(z)),
34         MAKE_TUPLE()
35     ));
36 
37     BOOST_HANA_CONSTANT_CHECK(hana::equal(
38         hana::take_while(MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), hana::not_equal.to(z)),
39         MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{})
40     ));
41     BOOST_HANA_CONSTANT_CHECK(hana::equal(
42         hana::take_while(MAKE_TUPLE(ct_eq<1>{}, z), hana::not_equal.to(z)),
43         MAKE_TUPLE(ct_eq<1>{})
44     ));
45     BOOST_HANA_CONSTANT_CHECK(hana::equal(
46         hana::take_while(MAKE_TUPLE(z, ct_eq<2>{}), hana::not_equal.to(z)),
47         MAKE_TUPLE()
48     ));
49 
50     BOOST_HANA_CONSTANT_CHECK(hana::equal(
51         hana::take_while(MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::not_equal.to(z)),
52         MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})
53     ));
54     BOOST_HANA_CONSTANT_CHECK(hana::equal(
55         hana::take_while(MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, z), hana::not_equal.to(z)),
56         MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{})
57     ));
58     BOOST_HANA_CONSTANT_CHECK(hana::equal(
59         hana::take_while(MAKE_TUPLE(ct_eq<1>{}, z, ct_eq<3>{}), hana::not_equal.to(z)),
60         MAKE_TUPLE(ct_eq<1>{})
61     ));
62     BOOST_HANA_CONSTANT_CHECK(hana::equal(
63         hana::take_while(MAKE_TUPLE(z, ct_eq<2>{}, ct_eq<3>{}), hana::not_equal.to(z)),
64         MAKE_TUPLE()
65     ));
66 }};
67 
68 #endif // !BOOST_HANA_TEST_AUTO_TAKE_WHILE_HPP
69