]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/string/to.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / test / string / to.cpp
1 // Copyright Louis Dionne 2013-2016
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/core/to.hpp>
7 #include <boost/hana/string.hpp>
8
9 #include <cstring>
10 namespace hana = boost::hana;
11
12
13 static_assert(hana::is_convertible<hana::string_tag, char const*>{}, "");
14 static_assert(!hana::is_embedded<hana::string_tag, char const*>{}, "");
15
16 int main() {
17 BOOST_HANA_RUNTIME_CHECK(std::strcmp(
18 hana::to<char const*>(BOOST_HANA_STRING("")),
19 ""
20 ) == 0);
21
22 BOOST_HANA_RUNTIME_CHECK(std::strcmp(
23 hana::to<char const*>(BOOST_HANA_STRING("a")),
24 "a"
25 ) == 0);
26
27 BOOST_HANA_RUNTIME_CHECK(std::strcmp(
28 hana::to<char const*>(BOOST_HANA_STRING("ab")),
29 "ab"
30 ) == 0);
31
32 BOOST_HANA_RUNTIME_CHECK(std::strcmp(
33 hana::to<char const*>(BOOST_HANA_STRING("abc")),
34 "abc"
35 ) == 0);
36
37 BOOST_HANA_RUNTIME_CHECK(std::strcmp(
38 hana::to<char const*>(BOOST_HANA_STRING("abcd")),
39 "abcd"
40 ) == 0);
41
42 // make sure we can turn a non-constexpr hana::string
43 // into a constexpr char const*
44 auto str = BOOST_HANA_STRING("abcdef");
45 constexpr char const* c_str = hana::to<char const*>(str);
46 (void)c_str;
47 }