summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/test/experimental/printable
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/hana/test/experimental/printable')
-rw-r--r--src/boost/libs/hana/test/experimental/printable/map.cpp51
-rw-r--r--src/boost/libs/hana/test/experimental/printable/metafunction.cpp45
-rw-r--r--src/boost/libs/hana/test/experimental/printable/optional.cpp29
-rw-r--r--src/boost/libs/hana/test/experimental/printable/pair.cpp38
-rw-r--r--src/boost/libs/hana/test/experimental/printable/set.cpp48
-rw-r--r--src/boost/libs/hana/test/experimental/printable/string.cpp45
-rw-r--r--src/boost/libs/hana/test/experimental/printable/tuple.cpp50
-rw-r--r--src/boost/libs/hana/test/experimental/printable/type.cpp35
8 files changed, 341 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/experimental/printable/map.cpp b/src/boost/libs/hana/test/experimental/printable/map.cpp
new file mode 100644
index 00000000..ad9bb575
--- /dev/null
+++ b/src/boost/libs/hana/test/experimental/printable/map.cpp
@@ -0,0 +1,51 @@
+// 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/experimental/printable.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/map.hpp>
+#include <boost/hana/pair.hpp>
+
+#include <sstream>
+#include <string>
+namespace hana = boost::hana;
+
+
+int main() {
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::make_map()
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "{}");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::make_map(hana::make_pair(hana::int_c<1>, 'x'))
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "{1 => x}");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::make_map(hana::make_pair(hana::int_c<1>, 'x'),
+ hana::make_pair(hana::int_c<2>, 'y'))
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "{1 => x, 2 => y}");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::make_map(hana::make_pair(hana::int_c<1>, 'x'),
+ hana::make_pair(hana::int_c<2>, 'y'),
+ hana::make_pair(hana::int_c<3>, 'z'))
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "{1 => x, 2 => y, 3 => z}");
+ }
+}
diff --git a/src/boost/libs/hana/test/experimental/printable/metafunction.cpp b/src/boost/libs/hana/test/experimental/printable/metafunction.cpp
new file mode 100644
index 00000000..5cfdb6a6
--- /dev/null
+++ b/src/boost/libs/hana/test/experimental/printable/metafunction.cpp
@@ -0,0 +1,45 @@
+// Copyright Jason Rice 2016
+// 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/experimental/printable.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/type.hpp>
+
+#include <regex>
+#include <sstream>
+namespace hana = boost::hana;
+
+namespace foo {
+ template <typename T> struct my_template { };
+ template <typename ...> struct my_mf { struct type; };
+ struct my_mf_class { template <typename ...> struct apply { struct type; }; };
+}
+
+int main() {
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::template_<foo::my_template>
+ );
+ BOOST_HANA_RUNTIME_CHECK(std::regex_match(ss.str(),
+ std::regex("template<(?:struct )?foo::my_template>")));
+ }
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::metafunction<foo::my_mf>
+ );
+ BOOST_HANA_RUNTIME_CHECK(std::regex_match(ss.str(),
+ std::regex("metafunction<(?:struct )?foo::my_mf>")));
+ }
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::metafunction_class<foo::my_mf_class>
+ );
+ BOOST_HANA_RUNTIME_CHECK(std::regex_match(ss.str(),
+ std::regex("metafunction_class<(?:struct )?foo::my_mf_class>")));
+ }
+}
diff --git a/src/boost/libs/hana/test/experimental/printable/optional.cpp b/src/boost/libs/hana/test/experimental/printable/optional.cpp
new file mode 100644
index 00000000..c963204c
--- /dev/null
+++ b/src/boost/libs/hana/test/experimental/printable/optional.cpp
@@ -0,0 +1,29 @@
+// Copyright Jason Rice 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 <boost/hana/assert.hpp>
+#include <boost/hana/experimental/printable.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/optional.hpp>
+
+#include <sstream>
+namespace hana = boost::hana;
+
+
+int main() {
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::just(hana::int_c<5>)
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "just(5)");
+ }
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::nothing
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "nothing");
+ }
+}
diff --git a/src/boost/libs/hana/test/experimental/printable/pair.cpp b/src/boost/libs/hana/test/experimental/printable/pair.cpp
new file mode 100644
index 00000000..4d592fb3
--- /dev/null
+++ b/src/boost/libs/hana/test/experimental/printable/pair.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/assert.hpp>
+#include <boost/hana/experimental/printable.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/pair.hpp>
+
+#include <sstream>
+namespace hana = boost::hana;
+
+
+int main() {
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::make_pair(1, hana::int_c<1>)
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 1)");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::make_pair(1, hana::int_c<2>)
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2)");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::make_pair('x', hana::int_c<2>)
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "(x, 2)");
+ }
+}
diff --git a/src/boost/libs/hana/test/experimental/printable/set.cpp b/src/boost/libs/hana/test/experimental/printable/set.cpp
new file mode 100644
index 00000000..7a939944
--- /dev/null
+++ b/src/boost/libs/hana/test/experimental/printable/set.cpp
@@ -0,0 +1,48 @@
+// 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/experimental/printable.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/set.hpp>
+#include <boost/hana/string.hpp>
+
+#include <sstream>
+#include <string>
+namespace hana = boost::hana;
+
+
+int main() {
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::make_set()
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "{}");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::make_set(hana::int_c<1>)
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "{1}");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::make_set(hana::int_c<1>, BOOST_HANA_STRING("3456"))
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "{1, \"3456\"}");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ hana::make_set(hana::char_c<'x'>, BOOST_HANA_STRING("3456"))
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "{x, \"3456\"}");
+ }
+}
diff --git a/src/boost/libs/hana/test/experimental/printable/string.cpp b/src/boost/libs/hana/test/experimental/printable/string.cpp
new file mode 100644
index 00000000..419e06ad
--- /dev/null
+++ b/src/boost/libs/hana/test/experimental/printable/string.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/experimental/printable.hpp>
+#include <boost/hana/string.hpp>
+
+#include <sstream>
+namespace hana = boost::hana;
+
+
+int main() {
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ BOOST_HANA_STRING("")
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "\"\"");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ BOOST_HANA_STRING("x")
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "\"x\"");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ BOOST_HANA_STRING("xy")
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "\"xy\"");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(
+ BOOST_HANA_STRING("xyz")
+ );
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "\"xyz\"");
+ }
+}
diff --git a/src/boost/libs/hana/test/experimental/printable/tuple.cpp b/src/boost/libs/hana/test/experimental/printable/tuple.cpp
new file mode 100644
index 00000000..db53626b
--- /dev/null
+++ b/src/boost/libs/hana/test/experimental/printable/tuple.cpp
@@ -0,0 +1,50 @@
+// 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/experimental/printable.hpp>
+#include <boost/hana/tuple.hpp>
+
+#include <sstream>
+#include <string>
+namespace hana = boost::hana;
+
+
+int main() {
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(hana::make_tuple());
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "()");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(hana::make_tuple(1));
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1)");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(hana::make_tuple(1, 2));
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2)");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(hana::make_tuple(1, '2', "3456"));
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2, 3456)");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(hana::make_tuple(1, '2', hana::make_tuple()));
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2, ())");
+ }
+
+ {
+ std::ostringstream ss;
+ ss << hana::experimental::print(hana::make_tuple(1, '2', hana::make_tuple(3.3, '4')));
+ BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2, (3.3, 4))");
+ }
+}
diff --git a/src/boost/libs/hana/test/experimental/printable/type.cpp b/src/boost/libs/hana/test/experimental/printable/type.cpp
new file mode 100644
index 00000000..718cdc0c
--- /dev/null
+++ b/src/boost/libs/hana/test/experimental/printable/type.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/experimental/printable.hpp>
+#include <boost/hana/type.hpp>
+
+#include <iostream>
+namespace hana = boost::hana;
+
+
+template <typename ...T>
+struct Template { };
+
+int main() {
+ // Since demangling may not always be available, and since that's not
+ // our job to test this (but Boost.Core's job), we don't test the
+ // actual demangling of types. We merely print a type to make sure
+ // things don't blow up stupidly, but we can't really test more than
+ // that.
+
+ std::cout << hana::experimental::print(hana::type_c<void>) << std::endl;
+
+ std::cout << hana::experimental::print(hana::type_c<int>) << std::endl;
+
+ std::cout << hana::experimental::print(hana::type_c<int const>) << std::endl;
+
+ std::cout << hana::experimental::print(hana::type_c<int&>) << std::endl;
+
+ std::cout << hana::experimental::print(hana::type_c<int const&>) << std::endl;
+
+ std::cout << hana::experimental::print(hana::type_c<int(&)[]>) << std::endl;
+
+ std::cout << hana::experimental::print(hana::type_c<Template<void, char const*>>) << std::endl;
+}