Kylin/UnitTest/HttpProxy/BoostUrlTest.cpp

20 lines
929 B
C++

#include "BoostLog.h"
#include <boost/test/unit_test.hpp>
#include <boost/url/parse_path.hpp>
#include <boost/url/url_view.hpp>
BOOST_AUTO_TEST_CASE(BoostUrlTest) {
boost::urls::url_view u("https://user:pass@example.com:443/%E5%B7%A5%E4%BD%9C%E7%AC%94%E8%AE%B0/path/to/"
"my%2dfile.txt?id=42&name=John%20Doe%20Jingleheimer%2DSchmidt#page%20anchor");
BOOST_CHECK_EQUAL(u.scheme(), "https");
BOOST_CHECK_EQUAL(u.authority().buffer(), "user:pass@example.com:443");
BOOST_CHECK_EQUAL(u.userinfo(), "user:pass");
BOOST_CHECK_EQUAL(u.user(), "user");
BOOST_CHECK_EQUAL(u.password(), "pass");
BOOST_CHECK_EQUAL(u.host(), "example.com");
BOOST_CHECK_EQUAL(u.port(), "443");
BOOST_CHECK_EQUAL(u.path(), "/工作笔记/path/to/my-file.txt");
BOOST_CHECK_EQUAL(u.query(), "id=42&name=John Doe Jingleheimer-Schmidt");
BOOST_CHECK_EQUAL(u.fragment(), "page anchor");
}