summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/test/assert
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/hana/test/assert')
-rw-r--r--src/boost/libs/hana/test/assert/commas.cpp35
-rw-r--r--src/boost/libs/hana/test/assert/constant.cpp53
-rw-r--r--src/boost/libs/hana/test/assert/constexpr.cpp30
-rw-r--r--src/boost/libs/hana/test/assert/flexible.cpp34
-rw-r--r--src/boost/libs/hana/test/assert/lambdas.cpp25
-rw-r--r--src/boost/libs/hana/test/assert/runtime.cpp22
6 files changed, 199 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/assert/commas.cpp b/src/boost/libs/hana/test/assert/commas.cpp
new file mode 100644
index 000000000..0027c4801
--- /dev/null
+++ b/src/boost/libs/hana/test/assert/commas.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 <support/cnumeric.hpp>
+namespace hana = boost::hana;
+
+
+// This test makes sure that we can use conditions with multiple comma-separated
+// arguments to the non-MSG versions of the BOOST_HANA_XXX_ASSERT macros.
+
+template <bool value, typename ...>
+bool runtime_bool() { return value; }
+
+template <bool value, typename ...>
+auto constant_bool() { return make_cnumeric<bool, value>(); }
+
+int main() {
+ BOOST_HANA_CONSTANT_ASSERT(constant_bool<true, void>());
+ BOOST_HANA_CONSTANT_ASSERT(constant_bool<true, void, void>());
+ BOOST_HANA_CONSTANT_ASSERT(constant_bool<true, void, void, void>());
+
+ BOOST_HANA_RUNTIME_ASSERT(runtime_bool<true, void>());
+ BOOST_HANA_RUNTIME_ASSERT(runtime_bool<true, void, void>());
+ BOOST_HANA_RUNTIME_ASSERT(runtime_bool<true, void, void, void>());
+
+ BOOST_HANA_ASSERT(runtime_bool<true, void>());
+ BOOST_HANA_ASSERT(runtime_bool<true, void, void>());
+ BOOST_HANA_ASSERT(runtime_bool<true, void, void, void>());
+ BOOST_HANA_ASSERT(constant_bool<true, void>());
+ BOOST_HANA_ASSERT(constant_bool<true, void, void>());
+ BOOST_HANA_ASSERT(constant_bool<true, void, void, void>());
+}
diff --git a/src/boost/libs/hana/test/assert/constant.cpp b/src/boost/libs/hana/test/assert/constant.cpp
new file mode 100644
index 000000000..3eca58c18
--- /dev/null
+++ b/src/boost/libs/hana/test/assert/constant.cpp
@@ -0,0 +1,53 @@
+// 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 <support/cnumeric.hpp>
+namespace hana = boost::hana;
+
+
+template <bool value>
+auto constant_bool() { return make_cnumeric<bool, value>(); }
+
+template <bool value>
+constexpr auto constexpr_constant_bool() { return make_cnumeric<bool, value>(); }
+
+
+// Make sure it works at global scope
+BOOST_HANA_CONSTANT_ASSERT(constant_bool<true>());
+BOOST_HANA_CONSTANT_ASSERT_MSG(constant_bool<true>(), "message");
+
+// Make sure it works at namespace scope
+namespace ns {
+ BOOST_HANA_CONSTANT_ASSERT(constant_bool<true>());
+ BOOST_HANA_CONSTANT_ASSERT_MSG(constant_bool<true>(), "message");
+}
+
+// Make sure it works in a constexpr context
+constexpr bool constexpr_context() {
+ BOOST_HANA_CONSTANT_ASSERT(constexpr_constant_bool<true>());
+ BOOST_HANA_CONSTANT_ASSERT_MSG(constexpr_constant_bool<true>(), "message");
+ return true;
+}
+static_assert(constexpr_context(), "");
+
+
+int main() {
+ // Make sure it works at function scope
+ BOOST_HANA_CONSTANT_ASSERT(constant_bool<true>());
+ BOOST_HANA_CONSTANT_ASSERT_MSG(constant_bool<true>(), "message");
+
+ // Make sure it works inside a lambda
+ auto lambda = []{
+ BOOST_HANA_CONSTANT_ASSERT(constant_bool<true>());
+ BOOST_HANA_CONSTANT_ASSERT_MSG(constant_bool<true>(), "message");
+ };
+ lambda();
+
+ // Make sure we can reference a local variable
+ auto yes = constant_bool<true>();
+ BOOST_HANA_CONSTANT_ASSERT(yes);
+ BOOST_HANA_CONSTANT_ASSERT_MSG(yes, "message");
+}
diff --git a/src/boost/libs/hana/test/assert/constexpr.cpp b/src/boost/libs/hana/test/assert/constexpr.cpp
new file mode 100644
index 000000000..dd26c34cd
--- /dev/null
+++ b/src/boost/libs/hana/test/assert/constexpr.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>
+namespace hana = boost::hana;
+
+
+template <bool value>
+bool runtime_bool() { return value; }
+
+template <bool value>
+constexpr bool constexpr_bool() { return value; }
+
+
+int main() {
+ // Make sure it works at function scope
+ BOOST_HANA_CONSTEXPR_ASSERT(runtime_bool<true>());
+ BOOST_HANA_CONSTEXPR_ASSERT(constexpr_bool<true>());
+ BOOST_HANA_CONSTEXPR_ASSERT_MSG(runtime_bool<true>(), "message");
+ BOOST_HANA_CONSTEXPR_ASSERT_MSG(constexpr_bool<true>(), "message");
+
+ // Make sure we can reference a local variable
+ auto rt_yes = runtime_bool<true>();
+ constexpr auto cx_yes = constexpr_bool<true>();
+ BOOST_HANA_CONSTEXPR_ASSERT(rt_yes);
+ BOOST_HANA_CONSTEXPR_ASSERT(cx_yes);
+ BOOST_HANA_CONSTEXPR_ASSERT_MSG(rt_yes, "message");
+ BOOST_HANA_CONSTEXPR_ASSERT_MSG(cx_yes, "message");
+}
diff --git a/src/boost/libs/hana/test/assert/flexible.cpp b/src/boost/libs/hana/test/assert/flexible.cpp
new file mode 100644
index 000000000..207eb4d8b
--- /dev/null
+++ b/src/boost/libs/hana/test/assert/flexible.cpp
@@ -0,0 +1,34 @@
+// 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 <support/cnumeric.hpp>
+namespace hana = boost::hana;
+
+
+template <bool value>
+bool runtime_bool() { return value; }
+
+template <bool value>
+auto constant_bool() { return make_cnumeric<bool, value>(); }
+
+
+int main() {
+ // Make sure it works at function scope
+ BOOST_HANA_ASSERT(runtime_bool<true>());
+ BOOST_HANA_ASSERT(constant_bool<true>());
+
+ BOOST_HANA_ASSERT_MSG(runtime_bool<true>(), "message");
+ BOOST_HANA_ASSERT_MSG(constant_bool<true>(), "message");
+
+ // Make sure we can reference a local variable
+ auto ct_yes = constant_bool<true>();
+ BOOST_HANA_ASSERT(ct_yes);
+ BOOST_HANA_ASSERT_MSG(ct_yes, "message");
+
+ auto rt_yes = runtime_bool<true>();
+ BOOST_HANA_ASSERT(rt_yes);
+ BOOST_HANA_ASSERT_MSG(rt_yes, "message");
+}
diff --git a/src/boost/libs/hana/test/assert/lambdas.cpp b/src/boost/libs/hana/test/assert/lambdas.cpp
new file mode 100644
index 000000000..900dbd4e5
--- /dev/null
+++ b/src/boost/libs/hana/test/assert/lambdas.cpp
@@ -0,0 +1,25 @@
+// 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 <support/cnumeric.hpp>
+namespace hana = boost::hana;
+
+
+// This test makes sure that we can use lambdas inside the various
+// BOOST_HANA_XXX_ASSERT macros.
+
+template <bool value>
+bool runtime_bool() { return value; }
+
+template <bool value>
+auto constant_bool() { return make_cnumeric<bool, value>(); }
+
+int main() {
+ BOOST_HANA_CONSTANT_ASSERT([]{ return constant_bool<true>(); }());
+ BOOST_HANA_RUNTIME_ASSERT([]{ return runtime_bool<true>(); }());
+ BOOST_HANA_ASSERT([] { return constant_bool<true>(); }());
+ BOOST_HANA_ASSERT([] { return runtime_bool<true>(); }());
+}
diff --git a/src/boost/libs/hana/test/assert/runtime.cpp b/src/boost/libs/hana/test/assert/runtime.cpp
new file mode 100644
index 000000000..7db4e4bef
--- /dev/null
+++ b/src/boost/libs/hana/test/assert/runtime.cpp
@@ -0,0 +1,22 @@
+// 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>
+namespace hana = boost::hana;
+
+
+template <bool value>
+bool runtime_bool() { return value; }
+
+
+int main() {
+ // Make sure it works at function scope
+ BOOST_HANA_RUNTIME_ASSERT(runtime_bool<true>());
+ BOOST_HANA_RUNTIME_ASSERT_MSG(runtime_bool<true>(), "message");
+
+ // Make sure we can reference a local variable
+ auto yes = runtime_bool<true>();
+ BOOST_HANA_RUNTIME_ASSERT(yes);
+ BOOST_HANA_RUNTIME_ASSERT_MSG(yes, "message");
+}