summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/test/ext/std/pair
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/hana/test/ext/std/pair')
-rw-r--r--src/boost/libs/hana/test/ext/std/pair/first_second.cpp30
-rw-r--r--src/boost/libs/hana/test/ext/std/pair/issue_90.cpp44
-rw-r--r--src/boost/libs/hana/test/ext/std/pair/laws.cpp41
-rw-r--r--src/boost/libs/hana/test/ext/std/pair/make.cpp26
4 files changed, 141 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/ext/std/pair/first_second.cpp b/src/boost/libs/hana/test/ext/std/pair/first_second.cpp
new file mode 100644
index 000000000..a44ed1cc3
--- /dev/null
+++ b/src/boost/libs/hana/test/ext/std/pair/first_second.cpp
@@ -0,0 +1,30 @@
+// 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/equal.hpp>
+#include <boost/hana/ext/std/pair.hpp>
+#include <boost/hana/first.hpp>
+#include <boost/hana/second.hpp>
+
+#include <laws/base.hpp>
+
+#include <utility>
+namespace hana = boost::hana;
+using hana::test::ct_eq;
+
+
+int main() {
+ // first
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::first(std::make_pair(ct_eq<0>{}, ct_eq<1>{})),
+ ct_eq<0>{}
+ ));
+
+ // second
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::second(std::make_pair(ct_eq<0>{}, ct_eq<1>{})),
+ ct_eq<1>{}
+ ));
+}
diff --git a/src/boost/libs/hana/test/ext/std/pair/issue_90.cpp b/src/boost/libs/hana/test/ext/std/pair/issue_90.cpp
new file mode 100644
index 000000000..d8f70c56e
--- /dev/null
+++ b/src/boost/libs/hana/test/ext/std/pair/issue_90.cpp
@@ -0,0 +1,44 @@
+// 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/ext/std/pair.hpp>
+#include <boost/hana/first.hpp>
+#include <boost/hana/second.hpp>
+
+#include <utility>
+namespace hana = boost::hana;
+
+
+template <typename T>
+T const& cref(T& t) { return t; }
+
+// a non-movable, non-copyable type
+template <int i>
+struct RefOnly {
+ RefOnly() = default;
+ RefOnly(RefOnly const&) = delete;
+ RefOnly(RefOnly&&) = delete;
+};
+
+int main() {
+ // This test makes sure that we return the proper reference types from
+ // `first` and `second`.
+ std::pair<RefOnly<0>, RefOnly<1>> p;
+
+ {
+ RefOnly<0>&& r1 = hana::first(std::move(p));
+ RefOnly<0>& r2 = hana::first(p);
+ RefOnly<0> const& r3 = hana::first(cref(p));
+
+ (void)r1; (void)r2; (void)r3;
+ }
+
+ {
+ RefOnly<1>&& r1 = hana::second(std::move(p));
+ RefOnly<1>& r2 = hana::second(p);
+ RefOnly<1> const& r3 = hana::second(cref(p));
+
+ (void)r1; (void)r2; (void)r3;
+ }
+}
diff --git a/src/boost/libs/hana/test/ext/std/pair/laws.cpp b/src/boost/libs/hana/test/ext/std/pair/laws.cpp
new file mode 100644
index 000000000..869001ab6
--- /dev/null
+++ b/src/boost/libs/hana/test/ext/std/pair/laws.cpp
@@ -0,0 +1,41 @@
+// 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/ext/std/pair.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>
+namespace hana = boost::hana;
+using hana::test::ct_eq;
+using hana::test::ct_ord;
+
+
+int main() {
+ auto eq_elems = hana::make_tuple(ct_eq<3>{}, ct_eq<4>{});
+
+ auto eqs = hana::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 = hana::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>{})
+ );
+
+ hana::test::TestComparable<hana::ext::std::pair_tag>{eqs};
+ hana::test::TestOrderable<hana::ext::std::pair_tag>{ords};
+ hana::test::TestFoldable<hana::ext::std::pair_tag>{eqs};
+ hana::test::TestProduct<hana::ext::std::pair_tag>{eq_elems};
+}
diff --git a/src/boost/libs/hana/test/ext/std/pair/make.cpp b/src/boost/libs/hana/test/ext/std/pair/make.cpp
new file mode 100644
index 000000000..f0cb9d297
--- /dev/null
+++ b/src/boost/libs/hana/test/ext/std/pair/make.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/equal.hpp>
+#include <boost/hana/ext/std/pair.hpp>
+
+#include <laws/base.hpp>
+
+#include <utility>
+namespace hana = boost::hana;
+using hana::test::ct_eq;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::make<hana::ext::std::pair_tag>(ct_eq<0>{}, ct_eq<1>{}),
+ std::make_pair(ct_eq<0>{}, ct_eq<1>{})
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::make<hana::ext::std::pair_tag>(ct_eq<3>{}, ct_eq<4>{}),
+ std::make_pair(ct_eq<3>{}, ct_eq<4>{})
+ ));
+}