2
0
mirror of https://github.com/boostorg/hana.git synced 2026-01-23 05:32:13 +00:00
Files
hana/test/pair.cpp
2015-02-01 10:35:15 -05:00

64 lines
1.4 KiB
C++

/*
@copyright Louis Dionne 2014
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#include <boost/hana/pair.hpp>
#include <boost/hana/assert.hpp>
#include <boost/hana/tuple.hpp>
#include <boost/hana/type.hpp>
#include <test/auto/base.hpp>
#include <test/auto/product.hpp>
#include <test/cnumeric.hpp>
#include <test/injection.hpp>
using namespace boost::hana;
namespace boost { namespace hana { namespace test {
template <>
auto instances<Pair> = tuple(type<Product>);
template <>
auto objects<Pair> = tuple(
pair(cnumeric<int, 0>, cnumeric<int, 0>)
, pair(cnumeric<int, 0>, cnumeric<int, 1>)
, pair(cnumeric<int, 1>, cnumeric<int, 0>)
, pair(cnumeric<int, 1>, cnumeric<int, 1>)
);
}}}
int main() {
test::check_datatype<Pair>();
// Product
{
using test::x;
// first
{
BOOST_HANA_CONSTANT_CHECK(equal(
first(pair(x<1>, x<2>)), x<1>
));
}
// second
{
BOOST_HANA_CONSTANT_CHECK(equal(
second(pair(x<1>, x<2>)), x<2>
));
}
// make
{
BOOST_HANA_CONSTANT_CHECK(equal(
make<Pair>(x<1>, x<2>),
pair(x<1>, x<2>)
));
}
}
}