]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/test/logical.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / logical.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
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#include <boost/hana/assert.hpp>
6#include <boost/hana/concept/logical.hpp>
7#include <boost/hana/equal.hpp>
8#include <boost/hana/eval_if.hpp>
9#include <boost/hana/functional/always.hpp>
10#include <boost/hana/not.hpp>
11#include <boost/hana/tuple.hpp>
12#include <boost/hana/while.hpp>
13
14#include <laws/logical.hpp>
15
16#include <vector>
17namespace hana = boost::hana;
18
19
20int main() {
21 hana::test::TestLogical<bool>{hana::make_tuple(true, false)};
22
23 // eval_if
24 {
25 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
26 hana::eval_if(true, hana::always(1), hana::always(2)),
27 1
28 ));
29
30 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
31 hana::eval_if(false, hana::always(1), hana::always(2)),
32 2
33 ));
34 }
35
36 // not_
37 {
38 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(hana::not_(true), false));
39 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(hana::not_(false), true));
40 }
41
42 // while_
43 {
44 auto less_than = [](auto n) {
45 return [n](auto v) { return v.size() < n; };
46 };
47 auto f = [](auto v) {
48 v.push_back(v.size());
49 return v;
50 };
51
52 BOOST_HANA_RUNTIME_CHECK(hana::equal(
53 hana::while_(less_than(0u), std::vector<int>{}, f),
54 std::vector<int>{}
55 ));
56
57 BOOST_HANA_RUNTIME_CHECK(hana::equal(
58 hana::while_(less_than(1u), std::vector<int>{}, f),
59 std::vector<int>{0}
60 ));
61
62 BOOST_HANA_RUNTIME_CHECK(hana::equal(
63 hana::while_(less_than(2u), std::vector<int>{}, f),
64 std::vector<int>{0, 1}
65 ));
66
67 BOOST_HANA_RUNTIME_CHECK(hana::equal(
68 hana::while_(less_than(3u), std::vector<int>{}, f),
69 std::vector<int>{0, 1, 2}
70 ));
71
72 BOOST_HANA_RUNTIME_CHECK(hana::equal(
73 hana::while_(less_than(4u), std::vector<int>{}, f),
74 std::vector<int>{0, 1, 2, 3}
75 ));
76
77 // Make sure it can be called with an lvalue state:
78 std::vector<int> v{};
79 BOOST_HANA_RUNTIME_CHECK(hana::equal(
80 hana::while_(less_than(4u), v, f),
81 std::vector<int>{0, 1, 2, 3}
82 ));
83 }
84}