diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/hana/test/string/cnstr.c_str.cpp | |
parent | Initial commit. (diff) | |
download | ceph-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/cnstr.c_str.cpp')
-rw-r--r-- | src/boost/libs/hana/test/string/cnstr.c_str.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
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'>)); + } +} |