From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/boost/tools/quickbook/test/unit/utils_test.cpp | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/boost/tools/quickbook/test/unit/utils_test.cpp (limited to 'src/boost/tools/quickbook/test/unit/utils_test.cpp') diff --git a/src/boost/tools/quickbook/test/unit/utils_test.cpp b/src/boost/tools/quickbook/test/unit/utils_test.cpp new file mode 100644 index 000000000..6a54dccfe --- /dev/null +++ b/src/boost/tools/quickbook/test/unit/utils_test.cpp @@ -0,0 +1,67 @@ + +/*============================================================================= + Copyright (c) 2017 Daniel James + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#include +#include "utils.hpp" + +#include + +void linkify_test() +{ + using quickbook::detail::linkify; + + BOOST_TEST(linkify("abc", "link") == "abc"); + BOOST_TEST( + linkify("abc", "link") == + "abc"); + BOOST_TEST( + linkify("abc def", "link") == + "abc def"); + BOOST_TEST( + linkify("abc def", "link") == + "abc def"); +} + +void decode_string_test() +{ + using quickbook::detail::decode_string; + BOOST_TEST_EQ(std::string(""), decode_string("<A&B>")); + BOOST_TEST_EQ(std::string(""), decode_string("<A&B>")); + BOOST_TEST_EQ(std::string("a"), decode_string("a")); + BOOST_TEST_EQ(std::string("OO"), decode_string("OO")); + // Unicode examples taken from wikipedia. + // https://en.wikipedia.org/wiki/UTF-8#Examples + BOOST_TEST_EQ( + std::string("\x24\xc2\xa2\xe2\x82\xAC\xF0\x90\x8D\x88"), + decode_string("$¢€𐍈")); +} + +void encode_string_test() +{ + using quickbook::detail::encode_string; + BOOST_TEST_EQ(std::string("<A&B>"), encode_string("")); +} + +void escape_uri_test() +{ + using quickbook::detail::escape_uri; + using quickbook::detail::partially_escape_uri; + + BOOST_TEST_EQ(std::string("%2520%2525%25"), escape_uri("%20%25%")); + BOOST_TEST_EQ(std::string("%20%25%25"), partially_escape_uri("%20%25%")); +} + +int main() +{ + linkify_test(); + decode_string_test(); + encode_string_test(); + escape_uri_test(); + return boost::report_errors(); +} -- cgit v1.2.3