summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/test/string
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/string
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.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/string')
-rw-r--r--src/boost/libs/hana/test/string/any_of.cpp29
-rw-r--r--src/boost/libs/hana/test/string/at.cpp53
-rw-r--r--src/boost/libs/hana/test/string/c_str.cpp51
-rw-r--r--src/boost/libs/hana/test/string/cnstr.c_str.cpp59
-rw-r--r--src/boost/libs/hana/test/string/cnstr.copy.cpp16
-rw-r--r--src/boost/libs/hana/test/string/cnstr.default.cpp13
-rw-r--r--src/boost/libs/hana/test/string/contains.cpp32
-rw-r--r--src/boost/libs/hana/test/string/drop_front_exactly.cpp44
-rw-r--r--src/boost/libs/hana/test/string/equal.cpp52
-rw-r--r--src/boost/libs/hana/test/string/find.cpp29
-rw-r--r--src/boost/libs/hana/test/string/find_if.cpp36
-rw-r--r--src/boost/libs/hana/test/string/front.cpp28
-rw-r--r--src/boost/libs/hana/test/string/hash.cpp33
-rw-r--r--src/boost/libs/hana/test/string/is_empty.cpp21
-rw-r--r--src/boost/libs/hana/test/string/laws.cpp95
-rw-r--r--src/boost/libs/hana/test/string/length.cpp30
-rw-r--r--src/boost/libs/hana/test/string/less.cpp65
-rw-r--r--src/boost/libs/hana/test/string/macro.cpp31
-rw-r--r--src/boost/libs/hana/test/string/make.cpp39
-rw-r--r--src/boost/libs/hana/test/string/plus.cpp35
-rw-r--r--src/boost/libs/hana/test/string/to.cpp47
-rw-r--r--src/boost/libs/hana/test/string/udl.cpp24
-rw-r--r--src/boost/libs/hana/test/string/unpack.cpp42
-rw-r--r--src/boost/libs/hana/test/string/zero.cpp17
24 files changed, 921 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/string/any_of.cpp b/src/boost/libs/hana/test/string/any_of.cpp
new file mode 100644
index 000000000..125a985d8
--- /dev/null
+++ b/src/boost/libs/hana/test/string/any_of.cpp
@@ -0,0 +1,29 @@
+// 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/any_of.hpp>
+#include <boost/hana/assert.hpp>
+#include <boost/hana/equal.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/not.hpp>
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::any_of(
+ BOOST_HANA_STRING("abcd"),
+ hana::equal.to(hana::char_c<'b'>)
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of(
+ BOOST_HANA_STRING(""),
+ hana::always(hana::true_c)
+ )));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of(
+ BOOST_HANA_STRING("abcd"),
+ hana::equal.to(hana::char_c<'z'>)
+ )));
+}
diff --git a/src/boost/libs/hana/test/string/at.cpp b/src/boost/libs/hana/test/string/at.cpp
new file mode 100644
index 000000000..ea0c24231
--- /dev/null
+++ b/src/boost/libs/hana/test/string/at.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 <boost/hana/at.hpp>
+#include <boost/hana/equal.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ BOOST_HANA_STRING("abcd")[hana::size_c<2>],
+ hana::char_c<'c'>
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::at(BOOST_HANA_STRING("a"), hana::size_c<0>),
+ hana::char_c<'a'>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::at(BOOST_HANA_STRING("ab"), hana::size_c<0>),
+ hana::char_c<'a'>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::at(BOOST_HANA_STRING("abc"), hana::size_c<0>),
+ hana::char_c<'a'>
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::at(BOOST_HANA_STRING("ab"), hana::size_c<1>),
+ hana::char_c<'b'>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::at(BOOST_HANA_STRING("abc"), hana::size_c<1>),
+ hana::char_c<'b'>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::at(BOOST_HANA_STRING("abcd"), hana::size_c<1>),
+ hana::char_c<'b'>
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::at(BOOST_HANA_STRING("abc"), hana::size_c<2>),
+ hana::char_c<'c'>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::at(BOOST_HANA_STRING("abcd"), hana::size_c<2>),
+ hana::char_c<'c'>
+ ));
+}
diff --git a/src/boost/libs/hana/test/string/c_str.cpp b/src/boost/libs/hana/test/string/c_str.cpp
new file mode 100644
index 000000000..b773fc207
--- /dev/null
+++ b/src/boost/libs/hana/test/string/c_str.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/string.hpp>
+
+#include <cstring>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_RUNTIME_CHECK(std::strcmp(
+ BOOST_HANA_STRING("").c_str(),
+ ""
+ ) == 0);
+
+ BOOST_HANA_RUNTIME_CHECK(std::strcmp(
+ BOOST_HANA_STRING("a").c_str(),
+ "a"
+ ) == 0);
+
+ BOOST_HANA_RUNTIME_CHECK(std::strcmp(
+ BOOST_HANA_STRING("ab").c_str(),
+ "ab"
+ ) == 0);
+
+ BOOST_HANA_RUNTIME_CHECK(std::strcmp(
+ BOOST_HANA_STRING("abc").c_str(),
+ "abc"
+ ) == 0);
+
+ BOOST_HANA_RUNTIME_CHECK(std::strcmp(
+ BOOST_HANA_STRING("abcd").c_str(),
+ "abcd"
+ ) == 0);
+
+ // make sure we can turn a non-constexpr hana::string
+ // into a constexpr char const*
+ {
+ auto str = BOOST_HANA_STRING("abcdef");
+ constexpr char const* c_str = str.c_str();
+ (void)c_str;
+ }
+
+ // make sure c_str is actually a static member function
+ {
+ constexpr char const* c_str = hana::string<'f', 'o', 'o'>::c_str();
+ (void)c_str;
+ }
+}
diff --git a/src/boost/libs/hana/test/string/cnstr.c_str.cpp b/src/boost/libs/hana/test/string/cnstr.c_str.cpp
new file mode 100644
index 000000000..e118f04f2
--- /dev/null
+++ b/src/boost/libs/hana/test/string/cnstr.c_str.cpp
@@ -0,0 +1,59 @@
+// 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/to.hpp>
+#include <boost/hana/equal.hpp>
+#include <boost/hana/ext/std/integral_constant.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/string.hpp>
+
+#include <type_traits>
+namespace hana = boost::hana;
+
+
+constexpr char const empty[] = "";
+constexpr char const a[] = "a";
+constexpr char const ab[] = "ab";
+constexpr char const abc[] = "abc";
+constexpr char const abcd[] = "abcd";
+
+int main() {
+ {
+ auto string = hana::to<hana::string_tag>(hana::integral_constant<char const*, empty>{});
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<>));
+ }
+
+ {
+ auto string = hana::to<hana::string_tag>(hana::integral_constant<char const*, a>{});
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<'a'>));
+ }
+
+ {
+ auto string = hana::to<hana::string_tag>(hana::integral_constant<char const*, ab>{});
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<'a', 'b'>));
+ }
+
+ {
+ auto string = hana::to<hana::string_tag>(hana::integral_constant<char const*, abc>{});
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<'a', 'b', 'c'>));
+ }
+
+ {
+ auto string = hana::to<hana::string_tag>(hana::integral_constant<char const*, abcd>{});
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<'a', 'b', 'c', 'd'>));
+ }
+
+ // Make sure it also works with std::integral_constant, for example
+ {
+ auto string = hana::to<hana::string_tag>(std::integral_constant<char const*, abcd>{});
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<'a', 'b', 'c', 'd'>));
+ }
+
+ // Make sure the `to_string` shortcut works
+ {
+ auto string = hana::to_string(hana::integral_constant<char const*, abcd>{});
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<'a', 'b', 'c', 'd'>));
+ }
+}
diff --git a/src/boost/libs/hana/test/string/cnstr.copy.cpp b/src/boost/libs/hana/test/string/cnstr.copy.cpp
new file mode 100644
index 000000000..08bda5b86
--- /dev/null
+++ b/src/boost/libs/hana/test/string/cnstr.copy.cpp
@@ -0,0 +1,16 @@
+// 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/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ using Str = decltype(hana::string_c<'a', 'b', 'c', 'd'>);
+ Str s1{};
+ Str s2(s1);
+ Str s3 = s1;
+
+ (void)s2; (void)s3;
+}
diff --git a/src/boost/libs/hana/test/string/cnstr.default.cpp b/src/boost/libs/hana/test/string/cnstr.default.cpp
new file mode 100644
index 000000000..b482e072e
--- /dev/null
+++ b/src/boost/libs/hana/test/string/cnstr.default.cpp
@@ -0,0 +1,13 @@
+// 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/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ using Str = decltype(hana::string_c<'a', 'b', 'c', 'd'>);
+ Str s{};
+ (void)s;
+}
diff --git a/src/boost/libs/hana/test/string/contains.cpp b/src/boost/libs/hana/test/string/contains.cpp
new file mode 100644
index 000000000..18ba68f91
--- /dev/null
+++ b/src/boost/libs/hana/test/string/contains.cpp
@@ -0,0 +1,32 @@
+// 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/integral_constant.hpp>
+#include <boost/hana/not.hpp>
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+struct invalid { };
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::contains(
+ BOOST_HANA_STRING("abcd"),
+ hana::char_c<'a'>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::contains(
+ BOOST_HANA_STRING("abcd"),
+ hana::char_c<'c'>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains(
+ BOOST_HANA_STRING("abcd"),
+ hana::char_c<'e'>
+ )));
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains(
+ BOOST_HANA_STRING("abcd"),
+ invalid{}
+ )));
+}
diff --git a/src/boost/libs/hana/test/string/drop_front_exactly.cpp b/src/boost/libs/hana/test/string/drop_front_exactly.cpp
new file mode 100644
index 000000000..fbcebe8e1
--- /dev/null
+++ b/src/boost/libs/hana/test/string/drop_front_exactly.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/assert.hpp>
+#include <boost/hana/drop_front_exactly.hpp>
+#include <boost/hana/equal.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::drop_front_exactly(BOOST_HANA_STRING("a")),
+ BOOST_HANA_STRING("")
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::drop_front_exactly(BOOST_HANA_STRING("ab")),
+ BOOST_HANA_STRING("b")
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::drop_front_exactly(BOOST_HANA_STRING("abc")),
+ BOOST_HANA_STRING("bc")
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::drop_front_exactly(BOOST_HANA_STRING("abcdefghijk")),
+ BOOST_HANA_STRING("bcdefghijk")
+ ));
+
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::drop_front_exactly(BOOST_HANA_STRING("abc"), hana::size_c<2>),
+ BOOST_HANA_STRING("c")
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::drop_front_exactly(BOOST_HANA_STRING("abcdefghijk"), hana::size_c<3>),
+ BOOST_HANA_STRING("defghijk")
+ ));
+}
diff --git a/src/boost/libs/hana/test/string/equal.cpp b/src/boost/libs/hana/test/string/equal.cpp
new file mode 100644
index 000000000..0e4ea9d8e
--- /dev/null
+++ b/src/boost/libs/hana/test/string/equal.cpp
@@ -0,0 +1,52 @@
+// 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/not.hpp>
+#include <boost/hana/not_equal.hpp> // for operator !=
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ // equal
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ BOOST_HANA_STRING("abcd"),
+ BOOST_HANA_STRING("abcd")
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(
+ BOOST_HANA_STRING("abcd"),
+ BOOST_HANA_STRING("abcde")
+ )));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(
+ BOOST_HANA_STRING("abcd"),
+ BOOST_HANA_STRING("")
+ )));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(
+ BOOST_HANA_STRING(""),
+ BOOST_HANA_STRING("abcde")
+ )));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ BOOST_HANA_STRING(""),
+ BOOST_HANA_STRING("")
+ ));
+
+ // check operators
+ BOOST_HANA_CONSTANT_CHECK(
+ BOOST_HANA_STRING("abcd")
+ ==
+ BOOST_HANA_STRING("abcd")
+ );
+
+ BOOST_HANA_CONSTANT_CHECK(
+ BOOST_HANA_STRING("abcd")
+ !=
+ BOOST_HANA_STRING("abc")
+ );
+}
diff --git a/src/boost/libs/hana/test/string/find.cpp b/src/boost/libs/hana/test/string/find.cpp
new file mode 100644
index 000000000..b8148e5ec
--- /dev/null
+++ b/src/boost/libs/hana/test/string/find.cpp
@@ -0,0 +1,29 @@
+// 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/find.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/optional.hpp>
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+struct invalid { };
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::find(BOOST_HANA_STRING("abcd"), hana::char_c<'a'>),
+ hana::just(hana::char_c<'a'>)
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::find(BOOST_HANA_STRING("abcd"), hana::char_c<'c'>),
+ hana::just(hana::char_c<'c'>)
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::find(BOOST_HANA_STRING("abcd"), invalid{}),
+ hana::nothing
+ ));
+}
diff --git a/src/boost/libs/hana/test/string/find_if.cpp b/src/boost/libs/hana/test/string/find_if.cpp
new file mode 100644
index 000000000..05d5e98b9
--- /dev/null
+++ b/src/boost/libs/hana/test/string/find_if.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/bool.hpp>
+#include <boost/hana/equal.hpp>
+#include <boost/hana/find_if.hpp>
+#include <boost/hana/functional/always.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/optional.hpp>
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::find_if(BOOST_HANA_STRING(""), hana::always(hana::true_c)),
+ hana::nothing
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::find_if(BOOST_HANA_STRING("abcd"), hana::equal.to(hana::char_c<'a'>)),
+ hana::just(hana::char_c<'a'>)
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::find_if(BOOST_HANA_STRING("abcd"), hana::equal.to(hana::char_c<'c'>)),
+ hana::just(hana::char_c<'c'>)
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::find_if(BOOST_HANA_STRING("abcd"), hana::equal.to(hana::char_c<'d'>)),
+ hana::just(hana::char_c<'d'>)
+ ));
+}
diff --git a/src/boost/libs/hana/test/string/front.cpp b/src/boost/libs/hana/test/string/front.cpp
new file mode 100644
index 000000000..c8659663b
--- /dev/null
+++ b/src/boost/libs/hana/test/string/front.cpp
@@ -0,0 +1,28 @@
+// 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/front.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::front(BOOST_HANA_STRING("a")),
+ hana::char_c<'a'>
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::front(BOOST_HANA_STRING("ab")),
+ hana::char_c<'a'>
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::front(BOOST_HANA_STRING("abc")),
+ hana::char_c<'a'>
+ ));
+}
diff --git a/src/boost/libs/hana/test/string/hash.cpp b/src/boost/libs/hana/test/string/hash.cpp
new file mode 100644
index 000000000..c5995e169
--- /dev/null
+++ b/src/boost/libs/hana/test/string/hash.cpp
@@ -0,0 +1,33 @@
+// 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/hash.hpp>
+#include <boost/hana/string.hpp>
+#include <boost/hana/type.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::hash(hana::string_c<>),
+ hana::type_c<hana::string<>>
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::hash(hana::string_c<'a'>),
+ hana::type_c<hana::string<'a'>>
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::hash(hana::string_c<'a', 'b'>),
+ hana::type_c<hana::string<'a', 'b'>>
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::hash(hana::string_c<'a', 'b', 'c'>),
+ hana::type_c<hana::string<'a', 'b', 'c'>>
+ ));
+}
diff --git a/src/boost/libs/hana/test/string/is_empty.cpp b/src/boost/libs/hana/test/string/is_empty.cpp
new file mode 100644
index 000000000..ab49d5768
--- /dev/null
+++ b/src/boost/libs/hana/test/string/is_empty.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/integral_constant.hpp>
+#include <boost/hana/is_empty.hpp>
+#include <boost/hana/not.hpp>
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::is_empty(BOOST_HANA_STRING("")));
+ BOOST_HANA_CONSTANT_CHECK(hana::is_empty(hana::string_c<>));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(BOOST_HANA_STRING("a"))));
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(BOOST_HANA_STRING("ab"))));
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(BOOST_HANA_STRING("abc"))));
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::string_c<'a'>)));
+}
diff --git a/src/boost/libs/hana/test/string/laws.cpp b/src/boost/libs/hana/test/string/laws.cpp
new file mode 100644
index 000000000..201c3f007
--- /dev/null
+++ b/src/boost/libs/hana/test/string/laws.cpp
@@ -0,0 +1,95 @@
+// 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/string.hpp>
+#include <boost/hana/tuple.hpp>
+
+#include <laws/comparable.hpp>
+#include <laws/foldable.hpp>
+#include <laws/hashable.hpp>
+#include <laws/iterable.hpp>
+#include <laws/monoid.hpp>
+#include <laws/orderable.hpp>
+#include <laws/searchable.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ // Comparable and Hashable
+ {
+ auto strings = hana::make_tuple(
+ BOOST_HANA_STRING(""),
+ BOOST_HANA_STRING("a"),
+ BOOST_HANA_STRING("ab"),
+ BOOST_HANA_STRING("abc"),
+ BOOST_HANA_STRING("abcd"),
+ BOOST_HANA_STRING("abcde"),
+ BOOST_HANA_STRING("ba")
+ );
+
+ hana::test::TestComparable<hana::string_tag>{strings};
+ hana::test::TestHashable<hana::string_tag>{strings};
+ }
+
+ // Monoid
+ {
+ auto strings = hana::make_tuple(
+ BOOST_HANA_STRING(""),
+ BOOST_HANA_STRING("a"),
+ BOOST_HANA_STRING("ab"),
+ BOOST_HANA_STRING("abc"),
+ BOOST_HANA_STRING("abcd"),
+ BOOST_HANA_STRING("abcde"),
+ BOOST_HANA_STRING("ba")
+ );
+
+ hana::test::TestMonoid<hana::string_tag>{strings};
+ }
+
+ // Foldable and Iterable
+ {
+ auto strings = hana::make_tuple(
+ BOOST_HANA_STRING(""),
+ BOOST_HANA_STRING("a"),
+ BOOST_HANA_STRING("ab"),
+ BOOST_HANA_STRING("abc"),
+ BOOST_HANA_STRING("abcd"),
+ BOOST_HANA_STRING("abcde"),
+ BOOST_HANA_STRING("ba"),
+ BOOST_HANA_STRING("afcd")
+ );
+
+ hana::test::TestFoldable<hana::string_tag>{strings};
+ hana::test::TestIterable<hana::string_tag>{strings};
+ }
+
+ // Orderable
+ {
+ auto strings = hana::make_tuple(
+ BOOST_HANA_STRING(""),
+ BOOST_HANA_STRING("a"),
+ BOOST_HANA_STRING("ab"),
+ BOOST_HANA_STRING("abc"),
+ BOOST_HANA_STRING("ba"),
+ BOOST_HANA_STRING("abd")
+ );
+
+ hana::test::TestOrderable<hana::string_tag>{strings};
+ }
+
+ // Searchable
+ {
+ auto keys = hana::tuple_c<char, 'a', 'f'>;
+ auto strings = hana::make_tuple(
+ BOOST_HANA_STRING(""),
+ BOOST_HANA_STRING("a"),
+ BOOST_HANA_STRING("ab"),
+ BOOST_HANA_STRING("abcd"),
+ BOOST_HANA_STRING("ba"),
+ BOOST_HANA_STRING("afcd")
+ );
+
+ hana::test::TestSearchable<hana::string_tag>{strings, keys};
+ }
+}
diff --git a/src/boost/libs/hana/test/string/length.cpp b/src/boost/libs/hana/test/string/length.cpp
new file mode 100644
index 000000000..02fd47183
--- /dev/null
+++ b/src/boost/libs/hana/test/string/length.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/integral_constant.hpp>
+#include <boost/hana/length.hpp>
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::length(BOOST_HANA_STRING("")),
+ hana::size_c<0>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::length(BOOST_HANA_STRING("a")),
+ hana::size_c<1>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::length(BOOST_HANA_STRING("ab")),
+ hana::size_c<2>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::length(BOOST_HANA_STRING("abc")),
+ hana::size_c<3>
+ ));
+}
diff --git a/src/boost/libs/hana/test/string/less.cpp b/src/boost/libs/hana/test/string/less.cpp
new file mode 100644
index 000000000..53ca1f1c8
--- /dev/null
+++ b/src/boost/libs/hana/test/string/less.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/greater.hpp>
+#include <boost/hana/greater_equal.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/less.hpp>
+#include <boost/hana/less_equal.hpp>
+#include <boost/hana/not.hpp>
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less(
+ BOOST_HANA_STRING(""),
+ BOOST_HANA_STRING("")
+ )));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::less(
+ BOOST_HANA_STRING(""),
+ BOOST_HANA_STRING("a")
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less(
+ BOOST_HANA_STRING("a"),
+ BOOST_HANA_STRING("")
+ )));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::less(
+ BOOST_HANA_STRING("a"),
+ BOOST_HANA_STRING("ab")
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less(
+ BOOST_HANA_STRING("ab"),
+ BOOST_HANA_STRING("ab")
+ )));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::less(
+ BOOST_HANA_STRING("abc"),
+ BOOST_HANA_STRING("abcde")
+ ));
+
+ BOOST_HANA_CONSTANT_CHECK(hana::less(
+ BOOST_HANA_STRING("abcde"),
+ BOOST_HANA_STRING("abfde")
+ ));
+
+ // check operators
+ BOOST_HANA_CONSTANT_CHECK(
+ BOOST_HANA_STRING("abc") < BOOST_HANA_STRING("abcd")
+ );
+ BOOST_HANA_CONSTANT_CHECK(
+ BOOST_HANA_STRING("abc") <= BOOST_HANA_STRING("abcd")
+ );
+ BOOST_HANA_CONSTANT_CHECK(
+ BOOST_HANA_STRING("abcd") > BOOST_HANA_STRING("abc")
+ );
+ BOOST_HANA_CONSTANT_CHECK(
+ BOOST_HANA_STRING("abcd") >= BOOST_HANA_STRING("abc")
+ );
+}
diff --git a/src/boost/libs/hana/test/string/macro.cpp b/src/boost/libs/hana/test/string/macro.cpp
new file mode 100644
index 000000000..d70e05150
--- /dev/null
+++ b/src/boost/libs/hana/test/string/macro.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/equal.hpp>
+#include <boost/hana/string.hpp>
+
+#include <type_traits>
+namespace hana = boost::hana;
+
+
+int main() {
+ // make sure string_c and BOOST_HANA_STRING give the same result
+
+ {
+ auto const s1 = BOOST_HANA_STRING("");
+ auto const s2 = hana::string_c<>;
+ static_assert(std::is_same<decltype(s1), decltype(s2)>::value, "");
+ }
+ {
+ auto const s1 = BOOST_HANA_STRING("a");
+ auto const s2 = hana::string_c<'a'>;
+ static_assert(std::is_same<decltype(s1), decltype(s2)>::value, "");
+ }
+ {
+ auto const s1 = BOOST_HANA_STRING("abcd");
+ auto const s2 = hana::string_c<'a', 'b', 'c', 'd'>;
+ static_assert(std::is_same<decltype(s1), decltype(s2)>::value, "");
+ }
+}
diff --git a/src/boost/libs/hana/test/string/make.cpp b/src/boost/libs/hana/test/string/make.cpp
new file mode 100644
index 000000000..03235eeea
--- /dev/null
+++ b/src/boost/libs/hana/test/string/make.cpp
@@ -0,0 +1,39 @@
+// 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/integral_constant.hpp>
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::make<hana::string_tag>(),
+ hana::string_c<>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::make<hana::string_tag>(hana::char_c<'a'>),
+ hana::string_c<'a'>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::make<hana::string_tag>(hana::char_c<'a'>, hana::char_c<'b'>),
+ hana::string_c<'a', 'b'>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::make<hana::string_tag>(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>),
+ hana::string_c<'a', 'b', 'c'>
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::make<hana::string_tag>(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>, hana::char_c<'d'>),
+ hana::string_c<'a', 'b', 'c', 'd'>
+ ));
+
+ // make sure make_string == make<string_tag>
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::make_string(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>),
+ hana::make<hana::string_tag>(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>)
+ ));
+}
diff --git a/src/boost/libs/hana/test/string/plus.cpp b/src/boost/libs/hana/test/string/plus.cpp
new file mode 100644
index 000000000..d256a5553
--- /dev/null
+++ b/src/boost/libs/hana/test/string/plus.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/equal.hpp>
+#include <boost/hana/plus.hpp>
+#include <boost/hana/string.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::plus(BOOST_HANA_STRING(""), BOOST_HANA_STRING("")),
+ BOOST_HANA_STRING("")
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::plus(BOOST_HANA_STRING("abcd"), BOOST_HANA_STRING("")),
+ BOOST_HANA_STRING("abcd")
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::plus(BOOST_HANA_STRING(""), BOOST_HANA_STRING("abcd")),
+ BOOST_HANA_STRING("abcd")
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::plus(BOOST_HANA_STRING("abcd"), BOOST_HANA_STRING("efg")),
+ BOOST_HANA_STRING("abcdefg")
+ ));
+
+ // check operator
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ BOOST_HANA_STRING("abc") + BOOST_HANA_STRING("def"),
+ BOOST_HANA_STRING("abcdef")
+ ));
+}
diff --git a/src/boost/libs/hana/test/string/to.cpp b/src/boost/libs/hana/test/string/to.cpp
new file mode 100644
index 000000000..68c3e00e6
--- /dev/null
+++ b/src/boost/libs/hana/test/string/to.cpp
@@ -0,0 +1,47 @@
+// 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/to.hpp>
+#include <boost/hana/string.hpp>
+
+#include <cstring>
+namespace hana = boost::hana;
+
+
+static_assert(hana::is_convertible<hana::string_tag, char const*>{}, "");
+static_assert(!hana::is_embedded<hana::string_tag, char const*>{}, "");
+
+int main() {
+ BOOST_HANA_RUNTIME_CHECK(std::strcmp(
+ hana::to<char const*>(BOOST_HANA_STRING("")),
+ ""
+ ) == 0);
+
+ BOOST_HANA_RUNTIME_CHECK(std::strcmp(
+ hana::to<char const*>(BOOST_HANA_STRING("a")),
+ "a"
+ ) == 0);
+
+ BOOST_HANA_RUNTIME_CHECK(std::strcmp(
+ hana::to<char const*>(BOOST_HANA_STRING("ab")),
+ "ab"
+ ) == 0);
+
+ BOOST_HANA_RUNTIME_CHECK(std::strcmp(
+ hana::to<char const*>(BOOST_HANA_STRING("abc")),
+ "abc"
+ ) == 0);
+
+ BOOST_HANA_RUNTIME_CHECK(std::strcmp(
+ hana::to<char const*>(BOOST_HANA_STRING("abcd")),
+ "abcd"
+ ) == 0);
+
+ // make sure we can turn a non-constexpr hana::string
+ // into a constexpr char const*
+ auto str = BOOST_HANA_STRING("abcdef");
+ constexpr char const* c_str = hana::to<char const*>(str);
+ (void)c_str;
+}
diff --git a/src/boost/libs/hana/test/string/udl.cpp b/src/boost/libs/hana/test/string/udl.cpp
new file mode 100644
index 000000000..899612b22
--- /dev/null
+++ b/src/boost/libs/hana/test/string/udl.cpp
@@ -0,0 +1,24 @@
+// 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/config.hpp>
+#include <boost/hana/string.hpp>
+
+#include <type_traits>
+namespace hana = boost::hana;
+
+
+int main() {
+ // Check the _s user-defined literal
+#ifdef BOOST_HANA_CONFIG_ENABLE_STRING_UDL
+
+ using namespace hana::literals;
+
+ constexpr auto s1 = "abcd"_s;
+ constexpr auto s2 = hana::string_c<'a', 'b', 'c', 'd'>;
+
+ static_assert(std::is_same<decltype(s1), decltype(s2)>::value, "");
+#endif
+}
diff --git a/src/boost/libs/hana/test/string/unpack.cpp b/src/boost/libs/hana/test/string/unpack.cpp
new file mode 100644
index 000000000..dea55db08
--- /dev/null
+++ b/src/boost/libs/hana/test/string/unpack.cpp
@@ -0,0 +1,42 @@
+// 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/integral_constant.hpp>
+#include <boost/hana/string.hpp>
+#include <boost/hana/unpack.hpp>
+
+#include <laws/base.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ hana::test::_injection<0> f{};
+
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::unpack(BOOST_HANA_STRING(""), f),
+ f()
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::unpack(BOOST_HANA_STRING("a"), f),
+ f(hana::char_c<'a'>)
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::unpack(BOOST_HANA_STRING("ab"), f),
+ f(hana::char_c<'a'>, hana::char_c<'b'>)
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::unpack(BOOST_HANA_STRING("abc"), f),
+ f(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>)
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::unpack(BOOST_HANA_STRING("abcd"), f),
+ f(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>, hana::char_c<'d'>)
+ ));
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::unpack(BOOST_HANA_STRING("abcde"), f),
+ f(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>, hana::char_c<'d'>, hana::char_c<'e'>)
+ ));
+}
diff --git a/src/boost/libs/hana/test/string/zero.cpp b/src/boost/libs/hana/test/string/zero.cpp
new file mode 100644
index 000000000..6cae8c070
--- /dev/null
+++ b/src/boost/libs/hana/test/string/zero.cpp
@@ -0,0 +1,17 @@
+// 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/string.hpp>
+#include <boost/hana/zero.hpp>
+namespace hana = boost::hana;
+
+
+int main() {
+ BOOST_HANA_CONSTANT_CHECK(hana::equal(
+ hana::zero<hana::string_tag>(),
+ BOOST_HANA_STRING("")
+ ));
+}