2
0
mirror of https://github.com/boostorg/hana.git synced 2026-02-02 08:52:11 +00:00
Files
hana/test/ext/std/pair.cpp

81 lines
2.2 KiB
C++

/*
@copyright Louis Dionne 2015
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/ext/std/pair.hpp>
#include <boost/hana/assert.hpp>
#include <boost/hana/tuple.hpp>
#include <laws/base.hpp>
#include <laws/comparable.hpp>
#include <laws/foldable.hpp>
#include <laws/orderable.hpp>
#include <laws/product.hpp>
#include <utility>
using namespace boost::hana;
using test::ct_eq;
using test::ct_ord;
int main() {
auto eq_elems = make<Tuple>(ct_eq<3>{}, ct_eq<4>{});
auto eqs = make<Tuple>(
std::make_pair(ct_eq<3>{}, ct_eq<3>{})
, std::make_pair(ct_eq<3>{}, ct_eq<4>{})
, std::make_pair(ct_eq<4>{}, ct_eq<3>{})
, std::make_pair(ct_eq<4>{}, ct_eq<4>{})
);
auto ords = make<Tuple>(
std::make_pair(ct_ord<3>{}, ct_ord<3>{})
, std::make_pair(ct_ord<3>{}, ct_ord<4>{})
, std::make_pair(ct_ord<4>{}, ct_ord<3>{})
, std::make_pair(ct_ord<4>{}, ct_ord<4>{})
);
//////////////////////////////////////////////////////////////////////////
// Comparable, Orderable, Foldable
//////////////////////////////////////////////////////////////////////////
test::TestComparable<ext::std::Pair>{eqs};
test::TestOrderable<ext::std::Pair>{ords};
test::TestFoldable<ext::std::Pair>{eqs};
//////////////////////////////////////////////////////////////////////////
// Product
//////////////////////////////////////////////////////////////////////////
{
// first
{
BOOST_HANA_CONSTANT_CHECK(equal(
first(std::make_pair(ct_eq<0>{}, ct_eq<1>{})),
ct_eq<0>{}
));
}
// second
{
BOOST_HANA_CONSTANT_CHECK(equal(
second(std::make_pair(ct_eq<0>{}, ct_eq<1>{})),
ct_eq<1>{}
));
}
// make
{
BOOST_HANA_CONSTANT_CHECK(equal(
make<ext::std::Pair>(ct_eq<0>{}, ct_eq<1>{}),
std::make_pair(ct_eq<0>{}, ct_eq<1>{})
));
}
// laws
test::TestProduct<ext::std::Pair>{eq_elems};
}
}