]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/test/ext/boost/fusion/tests.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / test / ext / boost / fusion / tests.hpp
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#ifndef BOOST_HANA_TEST_EXT_BOOST_FUSION_TESTS_HPP
6#define BOOST_HANA_TEST_EXT_BOOST_FUSION_TESTS_HPP
7
8#include <boost/hana/assert.hpp>
9#include <boost/hana/at.hpp>
10#include <boost/hana/concept/sequence.hpp>
11#include <boost/hana/core/make.hpp>
12#include <boost/hana/drop_front.hpp>
13#include <boost/hana/equal.hpp>
14#include <boost/hana/integral_constant.hpp>
15#include <boost/hana/is_empty.hpp>
16#include <boost/hana/length.hpp>
17#include <boost/hana/not.hpp>
18
19#include <laws/base.hpp>
20namespace hana = boost::hana;
21using hana::test::ct_eq;
22
23
24//
25// Before including this header, define the following macros:
26//
27// MAKE_TUPLE(...)
28// Must expand to a sequence holding __VA_ARGS__. A valid definition
29// would be hana::make_tuple(__VA_ARGS__).
30//
31// TUPLE_TYPE(...)
32// Must expand to the type of a sequence holding objects of type __VA_ARGS__.
33// A valid definition would be hana::tuple<__VA_ARGS__>.
34//
35// TUPLE_TAG
36// Must expand to the tag of the sequence. A valid definition would
37// be hana::tuple_tag.
38//
39
40
41struct undefined { };
42
43int main() {
44 //////////////////////////////////////////////////////////////////////////
45 // make<...>
46 //////////////////////////////////////////////////////////////////////////
47 {
48 BOOST_HANA_CONSTANT_CHECK(hana::equal(
49 MAKE_TUPLE(),
50 hana::make<TUPLE_TAG>()
51 ));
52
53 BOOST_HANA_CONSTANT_CHECK(hana::equal(
54 MAKE_TUPLE(ct_eq<0>{}),
55 hana::make<TUPLE_TAG>(ct_eq<0>{})
56 ));
57
58 BOOST_HANA_CONSTANT_CHECK(hana::equal(
59 MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}),
60 hana::make<TUPLE_TAG>(ct_eq<0>{}, ct_eq<1>{})
61 ));
62
63 BOOST_HANA_CONSTANT_CHECK(hana::equal(
64 MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}),
65 hana::make<TUPLE_TAG>(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})
66 ));
67 }
68
69 //////////////////////////////////////////////////////////////////////////
70 // drop_front
71 //////////////////////////////////////////////////////////////////////////
72 {
73 BOOST_HANA_CONSTANT_CHECK(hana::equal(
74 hana::drop_front(MAKE_TUPLE(ct_eq<0>{})),
75 MAKE_TUPLE()
76 ));
77
78 BOOST_HANA_CONSTANT_CHECK(hana::equal(
79 hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})),
80 MAKE_TUPLE(ct_eq<1>{})
81 ));
82
83 BOOST_HANA_CONSTANT_CHECK(hana::equal(
84 hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})),
85 MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{})
86 ));
87
88 BOOST_HANA_CONSTANT_CHECK(hana::equal(
89 hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})),
90 MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})
91 ));
92
93
94 BOOST_HANA_CONSTANT_CHECK(hana::equal(
95 hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<2>),
96 MAKE_TUPLE(ct_eq<2>{})
97 ));
98
99 BOOST_HANA_CONSTANT_CHECK(hana::equal(
100 hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::size_c<2>),
101 MAKE_TUPLE(ct_eq<2>{}, ct_eq<3>{})
102 ));
103
104 BOOST_HANA_CONSTANT_CHECK(hana::equal(
105 hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::size_c<3>),
106 MAKE_TUPLE(ct_eq<3>{})
107 ));
108
109 BOOST_HANA_CONSTANT_CHECK(hana::equal(
110 hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::size_c<5>),
111 MAKE_TUPLE()
112 ));
113 }
114
115 //////////////////////////////////////////////////////////////////////////
116 // at
117 //////////////////////////////////////////////////////////////////////////
118 {
119 BOOST_HANA_CONSTANT_CHECK(hana::equal(
120 hana::at_c<0>(MAKE_TUPLE(ct_eq<0>{})),
121 ct_eq<0>{}
122 ));
123
124 BOOST_HANA_CONSTANT_CHECK(hana::equal(
125 hana::at_c<0>(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})),
126 ct_eq<0>{}
127 ));
128 BOOST_HANA_CONSTANT_CHECK(hana::equal(
129 hana::at_c<1>(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})),
130 ct_eq<1>{}
131 ));
132
133 BOOST_HANA_CONSTANT_CHECK(hana::equal(
134 hana::at_c<0>(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})),
135 ct_eq<0>{}
136 ));
137 BOOST_HANA_CONSTANT_CHECK(hana::equal(
138 hana::at_c<1>(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})),
139 ct_eq<1>{}
140 ));
141 BOOST_HANA_CONSTANT_CHECK(hana::equal(
142 hana::at_c<2>(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})),
143 ct_eq<2>{}
144 ));
145 }
146
147 //////////////////////////////////////////////////////////////////////////
148 // is_empty
149 //////////////////////////////////////////////////////////////////////////
150 {
151 BOOST_HANA_CONSTANT_CHECK(hana::is_empty(
152 MAKE_TUPLE()
153 ));
154
155 BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(
156 MAKE_TUPLE(undefined{})
157 )));
158
159 BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(
160 MAKE_TUPLE(undefined{}, undefined{})
161 )));
162 }
163
164 //////////////////////////////////////////////////////////////////////////
165 // length
166 //////////////////////////////////////////////////////////////////////////
167 {
168 BOOST_HANA_CONSTANT_CHECK(hana::equal(
169 hana::length(MAKE_TUPLE()),
170 hana::size_c<0>
171 ));
172
173 BOOST_HANA_CONSTANT_CHECK(hana::equal(
174 hana::length(MAKE_TUPLE(undefined{})),
175 hana::size_c<1>
176 ));
177
178 BOOST_HANA_CONSTANT_CHECK(hana::equal(
179 hana::length(MAKE_TUPLE(undefined{}, undefined{})),
180 hana::size_c<2>
181 ));
182
183 BOOST_HANA_CONSTANT_CHECK(hana::equal(
184 hana::length(MAKE_TUPLE(undefined{}, undefined{}, undefined{})),
185 hana::size_c<3>
186 ));
187 }
188
189 //////////////////////////////////////////////////////////////////////////
190 // Sequence
191 //////////////////////////////////////////////////////////////////////////
192 {
193 static_assert(hana::Sequence<TUPLE_TAG>::value, "");
194 }
195}
196
197#endif // !BOOST_HANA_TEST_EXT_BOOST_FUSION_TESTS_HPP