/* @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 #include #include #include #include #include #include #include using namespace boost::hana; template constexpr auto array = std::array{{i...}}; namespace boost { namespace hana { namespace test { template <> auto instances = make( //! @todo Array is not actually a Sequence, because it can only hold //! homogeneous objects. #if 0 type, #endif type ); template <> auto objects = make( ::array<>, ::array<0>, ::array<0, 1>, ::array<0, 1, 2> ); }}} int main() { test::check_datatype(); // Iterable { // is_empty { BOOST_HANA_CONSTANT_CHECK(is_empty(array<>)); BOOST_HANA_CONSTANT_CHECK(not_(is_empty(array<0>))); BOOST_HANA_CONSTANT_CHECK(not_(is_empty(array<0, 1>))); } // head { BOOST_HANA_CONSTEXPR_CHECK(head(array<0>) == 0); BOOST_HANA_CONSTEXPR_CHECK(head(array<0, 1>) == 0); BOOST_HANA_CONSTEXPR_CHECK(head(array<0, 1, 2>) == 0); } // tail { BOOST_HANA_CONSTANT_CHECK(equal(tail(array<0>), array<>)); BOOST_HANA_CONSTEXPR_CHECK(equal(tail(array<0, 1>), array<1>)); BOOST_HANA_CONSTEXPR_CHECK(equal(tail(array<0, 1, 2>), array<1, 2>)); BOOST_HANA_CONSTEXPR_CHECK(equal(tail(array<0, 1, 2, 3>), array<1, 2, 3>)); } } // MonadPlus { // empty { BOOST_HANA_CONSTANT_CHECK(equal( empty(), std::array{} )); BOOST_HANA_CONSTANT_CHECK(equal( empty(), std::array{} )); BOOST_HANA_CONSTANT_CHECK(equal( empty(), std::array{} )); } // prepend { BOOST_HANA_CONSTEXPR_CHECK(equal( prepend(0, array<>), array<0> )); BOOST_HANA_CONSTEXPR_CHECK(equal( prepend(0, array<1>), array<0, 1> )); BOOST_HANA_CONSTEXPR_CHECK(equal( prepend(0, array<1, 2>), array<0, 1, 2> )); BOOST_HANA_CONSTEXPR_CHECK(equal( prepend(0, array<1, 2, 3>), array<0, 1, 2, 3> )); BOOST_HANA_CONSTEXPR_CHECK(equal( prepend(0, empty()), array<0> )); } } }