summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/test/detail/canonical_constant/laws.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/hana/test/detail/canonical_constant/laws.cpp
parentInitial commit. (diff)
downloadceph-upstream/16.2.11+ds.tar.xz
ceph-upstream/16.2.11+ds.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/hana/test/detail/canonical_constant/laws.cpp')
-rw-r--r--src/boost/libs/hana/test/detail/canonical_constant/laws.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/detail/canonical_constant/laws.cpp b/src/boost/libs/hana/test/detail/canonical_constant/laws.cpp
new file mode 100644
index 000000000..9dffcb526
--- /dev/null
+++ b/src/boost/libs/hana/test/detail/canonical_constant/laws.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/detail/canonical_constant.hpp>
+#include <boost/hana/tuple.hpp>
+
+#include <laws/comparable.hpp>
+#include <laws/constant.hpp>
+#include <laws/euclidean_ring.hpp>
+#include <laws/group.hpp>
+#include <laws/logical.hpp>
+#include <laws/monoid.hpp>
+#include <laws/orderable.hpp>
+#include <laws/ring.hpp>
+namespace hana = boost::hana;
+
+
+template <typename T, T v>
+struct canonical {
+ static constexpr T value = v;
+ using hana_tag = hana::detail::CanonicalConstant<T>;
+};
+
+int main() {
+ auto ints = hana::make_tuple(
+ canonical<int, -10>{}, canonical<int, -2>{}, canonical<int, 0>{},
+ canonical<int, 1>{}, canonical<int, 3>{}, canonical<int, 4>{}
+ );
+
+ auto bools = hana::make_tuple(canonical<bool, true>{}, canonical<bool, false>{});
+
+ // Constant
+ hana::test::TestConstant<hana::detail::CanonicalConstant<int>>{ints, hana::tuple_t<int, long, long long>};
+ hana::test::TestConstant<hana::detail::CanonicalConstant<bool>>{bools, hana::tuple_t<bool>};
+
+ // Monoid, Group, Ring, EuclideanRing
+ hana::test::TestMonoid<hana::detail::CanonicalConstant<int>>{ints};
+ hana::test::TestGroup<hana::detail::CanonicalConstant<int>>{ints};
+ hana::test::TestRing<hana::detail::CanonicalConstant<int>>{ints};
+ hana::test::TestEuclideanRing<hana::detail::CanonicalConstant<int>>{ints};
+
+ // Logical
+ {
+ auto ints = hana::make_tuple(
+ canonical<int, -2>{}, canonical<int, 0>{},
+ canonical<int, 1>{}, canonical<int, 3>{}
+ );
+ hana::test::TestLogical<hana::detail::CanonicalConstant<int>>{ints};
+ hana::test::TestLogical<hana::detail::CanonicalConstant<bool>>{bools};
+ }
+
+ // Comparable and Orderable
+ hana::test::TestComparable<hana::detail::CanonicalConstant<int>>{ints};
+ hana::test::TestOrderable<hana::detail::CanonicalConstant<int>>{ints};
+}