diff options
Diffstat (limited to '')
-rw-r--r-- | src/boost/libs/hana/test/range/at.cpp | 36 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/back.cpp | 31 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/contains.cpp | 56 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/drop_front.cpp | 75 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/drop_front_exactly.cpp | 63 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/equal.cpp | 65 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/find.cpp | 57 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/front.cpp | 36 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/is_empty.cpp | 26 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/laws.cpp | 38 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/length.cpp | 35 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/make.cpp | 21 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/maximum.cpp | 27 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/minimum.cpp | 27 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/product.cpp | 85 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/range_c.cpp | 40 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/sum.cpp | 85 | ||||
-rw-r--r-- | src/boost/libs/hana/test/range/unpack.cpp | 45 |
18 files changed, 848 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/range/at.cpp b/src/boost/libs/hana/test/range/at.cpp new file mode 100644 index 000000000..b57c4de8f --- /dev/null +++ b/src/boost/libs/hana/test/range/at.cpp @@ -0,0 +1,36 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/at.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<10>)[hana::int_c<2>], + hana::int_c<2> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(hana::make_range(hana::int_c<0>, hana::int_c<1>), hana::int_c<0>), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<0>), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<1>), + hana::int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(hana::make_range(hana::int_c<4>, hana::int_c<90>), hana::int_c<46>), + hana::int_c<50> + )); +} diff --git a/src/boost/libs/hana/test/range/back.cpp b/src/boost/libs/hana/test/range/back.cpp new file mode 100644 index 000000000..c6c666e6d --- /dev/null +++ b/src/boost/libs/hana/test/range/back.cpp @@ -0,0 +1,31 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/back.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::back(hana::make_range(hana::int_c<0>, hana::int_c<1>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::back(hana::make_range(hana::int_c<0>, hana::int_c<2>)), + hana::int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::back(hana::make_range(hana::int_c<0>, hana::int_c<3>)), + hana::int_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::back(hana::make_range(hana::int_c<3>, hana::int_c<6>)), + hana::int_c<5> + )); +} diff --git a/src/boost/libs/hana/test/range/contains.cpp b/src/boost/libs/hana/test/range/contains.cpp new file mode 100644 index 000000000..7a9c50823 --- /dev/null +++ b/src/boost/libs/hana/test/range/contains.cpp @@ -0,0 +1,56 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/contains.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/not.hpp> +#include <boost/hana/range.hpp> + +#include <support/cnumeric.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_range(hana::int_c<0>, hana::int_c<0>), + cnumeric<int, 0> + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_range(hana::int_c<0>, hana::int_c<1>), + cnumeric<int, 0> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_range(hana::int_c<0>, hana::int_c<10>), + cnumeric<int, 3> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_range(hana::int_c<0>, hana::int_c<10>), + cnumeric<int, 9> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_range(hana::int_c<-10>, hana::int_c<10>), + cnumeric<int, -10> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_range(hana::int_c<-10>, hana::int_c<10>), + cnumeric<int, -5> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_range(hana::int_c<-10>, hana::int_c<0>), + cnumeric<int, 3> + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_range(hana::int_c<0>, hana::int_c<10>), + cnumeric<int, 15> + ))); +} diff --git a/src/boost/libs/hana/test/range/drop_front.cpp b/src/boost/libs/hana/test/range/drop_front.cpp new file mode 100644 index 000000000..16c0e9ef0 --- /dev/null +++ b/src/boost/libs/hana/test/range/drop_front.cpp @@ -0,0 +1,75 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/drop_front.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<0>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<0>), hana::int_c<1>), + hana::make_range(hana::int_c<0>, hana::int_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<0>), hana::int_c<2>), + hana::make_range(hana::int_c<0>, hana::int_c<0>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<1>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<1>), hana::int_c<1>), + hana::make_range(hana::int_c<1>, hana::int_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<1>), hana::int_c<2>), + hana::make_range(hana::int_c<1>, hana::int_c<1>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<1>), + hana::make_range(hana::int_c<1>, hana::int_c<2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<2>), + hana::make_range(hana::int_c<2>, hana::int_c<2>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<1>), + hana::make_range(hana::int_c<1>, hana::int_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<2>), + hana::make_range(hana::int_c<2>, hana::int_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<3>), + hana::make_range(hana::int_c<3>, hana::int_c<3>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<20>, hana::int_c<50>), hana::int_c<10>), + hana::make_range(hana::int_c<30>, hana::int_c<50>) + )); +} diff --git a/src/boost/libs/hana/test/range/drop_front_exactly.cpp b/src/boost/libs/hana/test/range/drop_front_exactly.cpp new file mode 100644 index 000000000..da9644927 --- /dev/null +++ b/src/boost/libs/hana/test/range/drop_front_exactly.cpp @@ -0,0 +1,63 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/drop_front_exactly.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<0>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<0>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<1>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<1>), hana::int_c<1>), + hana::make_range(hana::int_c<1>, hana::int_c<1>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<1>), + hana::make_range(hana::int_c<1>, hana::int_c<2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<2>), + hana::make_range(hana::int_c<2>, hana::int_c<2>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<1>), + hana::make_range(hana::int_c<1>, hana::int_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<2>), + hana::make_range(hana::int_c<2>, hana::int_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<3>), + hana::make_range(hana::int_c<3>, hana::int_c<3>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<20>, hana::int_c<50>), hana::int_c<10>), + hana::make_range(hana::int_c<30>, hana::int_c<50>) + )); +} diff --git a/src/boost/libs/hana/test/range/equal.cpp b/src/boost/libs/hana/test/range/equal.cpp new file mode 100644 index 000000000..22babe501 --- /dev/null +++ b/src/boost/libs/hana/test/range/equal.cpp @@ -0,0 +1,65 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/not_equal.hpp> // for operator != +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK( + hana::make_range(hana::int_c<0>, hana::int_c<0>) == + hana::make_range(hana::int_c<0>, hana::int_c<0>) + ); + BOOST_HANA_CONSTANT_CHECK( + hana::make_range(hana::int_c<0>, hana::int_c<4>) != + hana::make_range(hana::int_c<0>, hana::int_c<0>) + ); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<1>) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<1>), + hana::make_range(hana::int_c<0>, hana::int_c<0>) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<1>), + hana::make_range(hana::int_c<0>, hana::int_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<2>), + hana::make_range(hana::int_c<0>, hana::int_c<1>) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<2>), + hana::make_range(hana::int_c<0>, hana::int_c<2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<0>), + hana::make_range(hana::int_c<2>, hana::int_c<2>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<2>, hana::int_c<4>), + hana::make_range(hana::int_c<2>, hana::int_c<4>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<-4>, hana::int_c<-3>), + hana::make_range(hana::int_c<-4>, hana::int_c<-3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<-4>, hana::int_c<2>), + hana::make_range(hana::int_c<-4>, hana::int_c<2>) + )); +} diff --git a/src/boost/libs/hana/test/range/find.cpp b/src/boost/libs/hana/test/range/find.cpp new file mode 100644 index 000000000..29954e8a9 --- /dev/null +++ b/src/boost/libs/hana/test/range/find.cpp @@ -0,0 +1,57 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/find.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/optional.hpp> +#include <boost/hana/range.hpp> + +#include <support/cnumeric.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<0>, hana::int_c<0>), cnumeric<int, 0>), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<0>, hana::int_c<1>), cnumeric<int, 0>), + hana::just(hana::int_c<0>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<0>, hana::int_c<10>), cnumeric<int, 3>), + hana::just(hana::int_c<3>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<0>, hana::int_c<10>), cnumeric<int, 9>), + hana::just(hana::int_c<9>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<-10>, hana::int_c<10>), cnumeric<int, -10>), + hana::just(hana::int_c<-10>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<-10>, hana::int_c<10>), cnumeric<int, -5>), + hana::just(hana::int_c<-5>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<-10>, hana::int_c<0>), cnumeric<int, 3>), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<0>, hana::int_c<10>), cnumeric<int, 15>), + hana::nothing + )); +} diff --git a/src/boost/libs/hana/test/range/front.cpp b/src/boost/libs/hana/test/range/front.cpp new file mode 100644 index 000000000..e3777a3b9 --- /dev/null +++ b/src/boost/libs/hana/test/range/front.cpp @@ -0,0 +1,36 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/front.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::make_range(hana::int_c<0>, hana::int_c<1>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::make_range(hana::int_c<0>, hana::int_c<2>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::make_range(hana::int_c<2>, hana::int_c<5>)), + hana::int_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::make_range(hana::int_c<5>, hana::int_c<6>)), + hana::int_c<5> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::make_range(hana::int_c<5>, hana::long_c<6>)), + hana::long_c<5> + )); +} diff --git a/src/boost/libs/hana/test/range/is_empty.cpp b/src/boost/libs/hana/test/range/is_empty.cpp new file mode 100644 index 000000000..5ad791374 --- /dev/null +++ b/src/boost/libs/hana/test/range/is_empty.cpp @@ -0,0 +1,26 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/is_empty.hpp> +#include <boost/hana/not.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::is_empty( + hana::make_range(hana::int_c<0>, hana::int_c<0>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + hana::make_range(hana::int_c<0>, hana::int_c<1>) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + hana::make_range(hana::int_c<0>, hana::int_c<2>) + ))); +} diff --git a/src/boost/libs/hana/test/range/laws.cpp b/src/boost/libs/hana/test/range/laws.cpp new file mode 100644 index 000000000..070913cba --- /dev/null +++ b/src/boost/libs/hana/test/range/laws.cpp @@ -0,0 +1,38 @@ +// Copyright Louis Dionne 2013-2017 +// 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/integral_constant.hpp> +#include <boost/hana/range.hpp> +#include <boost/hana/tuple.hpp> + +#include <laws/comparable.hpp> +#include <laws/foldable.hpp> +#include <laws/iterable.hpp> +#include <laws/searchable.hpp> + +#include <type_traits> +namespace hana = boost::hana; + + +int main() { + auto ranges = hana::make_tuple( + hana::make_range(hana::int_c<0>, hana::int_c<0>) + , hana::make_range(hana::int_c<0>, hana::int_c<1>) + , hana::make_range(hana::int_c<0>, hana::int_c<2>) + , hana::make_range(hana::int_c<1>, hana::int_c<1>) + , hana::make_range(hana::int_c<1>, hana::int_c<2>) + , hana::make_range(hana::int_c<1>, hana::int_c<3>) + , hana::make_range(hana::int_c<50>, hana::int_c<60>) + + , hana::make_range(hana::int_c<50>, hana::long_c<60>) + , hana::make_range(hana::long_c<50>, hana::int_c<60>) + ); + + auto integers = hana::tuple_c<int, 0, 1, 900>; + + hana::test::TestComparable<hana::range_tag>{ranges}; + hana::test::TestFoldable<hana::range_tag>{ranges}; + hana::test::TestIterable<hana::range_tag>{ranges}; + hana::test::TestSearchable<hana::range_tag>{ranges, integers}; +} diff --git a/src/boost/libs/hana/test/range/length.cpp b/src/boost/libs/hana/test/range/length.cpp new file mode 100644 index 000000000..3eb9799f7 --- /dev/null +++ b/src/boost/libs/hana/test/range/length.cpp @@ -0,0 +1,35 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/length.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_range(hana::int_c<0>, hana::int_c<0>)), + hana::size_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_range(hana::int_c<0>, hana::int_c<1>)), + hana::size_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_range(hana::int_c<0>, hana::int_c<2>)), + hana::size_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_range(hana::int_c<4>, hana::int_c<4>)), + hana::size_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_range(hana::int_c<4>, hana::int_c<10>)), + hana::size_c<6> + )); +} diff --git a/src/boost/libs/hana/test/range/make.cpp b/src/boost/libs/hana/test/range/make.cpp new file mode 100644 index 000000000..cd9fe94c5 --- /dev/null +++ b/src/boost/libs/hana/test/range/make.cpp @@ -0,0 +1,21 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/range.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; + + +int main() { + // make sure make<range_tag> works with arbitrary Constants + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make<hana::range_tag>(hana::test::_constant<1>{}, hana::test::_constant<4>{}), + hana::make_range(hana::integral_c<int, 1>, hana::integral_c<int, 4>) + )); +} diff --git a/src/boost/libs/hana/test/range/maximum.cpp b/src/boost/libs/hana/test/range/maximum.cpp new file mode 100644 index 000000000..ca98b16e8 --- /dev/null +++ b/src/boost/libs/hana/test/range/maximum.cpp @@ -0,0 +1,27 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/maximum.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::maximum(hana::make_range(hana::int_c<3>, hana::int_c<4>)), + hana::int_c<3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::maximum(hana::make_range(hana::int_c<3>, hana::int_c<5>)), + hana::int_c<4> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::maximum(hana::make_range(hana::int_c<-1>, hana::int_c<6>)), + hana::int_c<5> + )); +} diff --git a/src/boost/libs/hana/test/range/minimum.cpp b/src/boost/libs/hana/test/range/minimum.cpp new file mode 100644 index 000000000..3a5da38cc --- /dev/null +++ b/src/boost/libs/hana/test/range/minimum.cpp @@ -0,0 +1,27 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/minimum.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::minimum(hana::make_range(hana::int_c<3>, hana::int_c<4>)), + hana::int_c<3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::minimum(hana::make_range(hana::int_c<3>, hana::int_c<5>)), + hana::int_c<3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::minimum(hana::make_range(hana::int_c<-1>, hana::int_c<5>)), + hana::int_c<-1> + )); +} diff --git a/src/boost/libs/hana/test/range/product.cpp b/src/boost/libs/hana/test/range/product.cpp new file mode 100644 index 000000000..0a15a23c8 --- /dev/null +++ b/src/boost/libs/hana/test/range/product.cpp @@ -0,0 +1,85 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/product.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<-3>)), + hana::int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<-2>)), + hana::int_c<-3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<-1>)), + hana::int_c<-3 * -2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<0>)), + hana::int_c<-3 * -2 * -1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<1>)), + hana::int_c<-3 * -2 * -1 * 0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<2>)), + hana::int_c<-3 * -2 * -1 * 0 * 1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<3>)), + hana::int_c<-3 * -2 * -1 * 0 * 1 * 2> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<1>, hana::int_c<1>)), + hana::int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<1>, hana::int_c<2>)), + hana::int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<1>, hana::int_c<3>)), + hana::int_c<1 * 2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<1>, hana::int_c<4>)), + hana::int_c<1 * 2 * 3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<1>, hana::int_c<5>)), + hana::int_c<1 * 2 * 3 * 4> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<3>, hana::int_c<3>)), + hana::int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<3>, hana::int_c<4>)), + hana::int_c<3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<3>, hana::int_c<5>)), + hana::int_c<3 * 4> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<3>, hana::int_c<6>)), + hana::int_c<3 * 4 * 5> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<3>, hana::int_c<7>)), + hana::int_c<3 * 4 * 5 * 6> + )); +} diff --git a/src/boost/libs/hana/test/range/range_c.cpp b/src/boost/libs/hana/test/range/range_c.cpp new file mode 100644 index 000000000..9d384c2da --- /dev/null +++ b/src/boost/libs/hana/test/range/range_c.cpp @@ -0,0 +1,40 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/range.hpp> +namespace hana = boost::hana; + + +int main() { + using T = int; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::range_c<T, 0, 0>, + hana::make_range(hana::integral_c<T, 0>, hana::integral_c<T, 0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::range_c<T, 0, 1>, + hana::make_range(hana::integral_c<T, 0>, hana::integral_c<T, 1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::range_c<T, 0, 2>, + hana::make_range(hana::integral_c<T, 0>, hana::integral_c<T, 2>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::range_c<T, 1, 1>, + hana::make_range(hana::integral_c<T, 1>, hana::integral_c<T, 1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::range_c<T, 1, 2>, + hana::make_range(hana::integral_c<T, 1>, hana::integral_c<T, 2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::range_c<T, 1, 3>, + hana::make_range(hana::integral_c<T, 1>, hana::integral_c<T, 3>) + )); +} diff --git a/src/boost/libs/hana/test/range/sum.cpp b/src/boost/libs/hana/test/range/sum.cpp new file mode 100644 index 000000000..3575c3c9a --- /dev/null +++ b/src/boost/libs/hana/test/range/sum.cpp @@ -0,0 +1,85 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/range.hpp> +#include <boost/hana/sum.hpp> +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<-3>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<-2>)), + hana::int_c<-3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<-1>)), + hana::int_c<-3 + -2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<0>)), + hana::int_c<-3 + -2 + -1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<1>)), + hana::int_c<-3 + -2 + -1 + 0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<2>)), + hana::int_c<-3 + -2 + -1 + 0 + 1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<3>)), + hana::int_c<-3 + -2 + -1 + 0 + 1 + 2> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<0>, hana::int_c<0>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<0>, hana::int_c<1>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<0>, hana::int_c<2>)), + hana::int_c<0 + 1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<0>, hana::int_c<3>)), + hana::int_c<0 + 1 + 2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<0>, hana::int_c<4>)), + hana::int_c<0 + 1 + 2 + 3> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<3>, hana::int_c<3>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<3>, hana::int_c<4>)), + hana::int_c<3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<3>, hana::int_c<5>)), + hana::int_c<3 + 4> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<3>, hana::int_c<6>)), + hana::int_c<3 + 4 + 5> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<3>, hana::int_c<7>)), + hana::int_c<3 + 4 + 5 + 6> + )); +} diff --git a/src/boost/libs/hana/test/range/unpack.cpp b/src/boost/libs/hana/test/range/unpack.cpp new file mode 100644 index 000000000..45b2e7287 --- /dev/null +++ b/src/boost/libs/hana/test/range/unpack.cpp @@ -0,0 +1,45 @@ +// Copyright Louis Dionne 2013-2017 +// 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/assert.hpp> +#include <boost/hana/core/make.hpp> +#include <boost/hana/core/tag_of.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/range.hpp> +#include <boost/hana/unpack.hpp> + +#include <laws/base.hpp> + +#include <type_traits> +namespace hana = boost::hana; + + +int main() { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<0>), f), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<1>), f), + f(hana::int_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<2>), f), + f(hana::int_c<0>, hana::int_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<3>), f), + f(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>) + )); + + // Previously, we would only unpack with `std::size_t`s. Make + // sure this does not happen. + hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<1>), [](auto x) { + using T = hana::tag_of_t<decltype(x)>; + static_assert(std::is_same<typename T::value_type, int>{}, ""); + }); +} |