add boost url unit test for learn.
This commit is contained in:
parent
0edab61c09
commit
b8c3ed6b7d
3
.gitignore
vendored
3
.gitignore
vendored
@ -41,4 +41,5 @@ target_wrapper.*
|
||||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
build
|
||||
build
|
||||
logs
|
@ -27,6 +27,9 @@ add_executable(UnitTest main.cpp
|
||||
DataStructure/StaticQueueTest.cpp
|
||||
DataStructure/StaticStackTest.cpp
|
||||
DataStructure/StringTest.cpp
|
||||
|
||||
HttpProxy/BoostUrlTest.cpp
|
||||
|
||||
Universal/BoostLogTest.cpp
|
||||
)
|
||||
|
||||
@ -37,5 +40,6 @@ target_compile_definitions(UnitTest
|
||||
target_link_libraries(UnitTest
|
||||
PRIVATE Boost::unit_test_framework
|
||||
PRIVATE DataStructure
|
||||
PRIVATE HttpProxy
|
||||
PRIVATE Universal
|
||||
)
|
||||
|
19
UnitTest/HttpProxy/BoostUrlTest.cpp
Normal file
19
UnitTest/HttpProxy/BoostUrlTest.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#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");
|
||||
}
|
@ -47,6 +47,7 @@ function cmake_scan() {
|
||||
-S ${base_path} \
|
||||
-B ${build_path} \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DUNIT_TEST=ON \
|
||||
-DBOOST_ROOT=${libraries_root}/boost_1_84_0 \
|
||||
-DZeroMQ_ROOT=${libraries_root}/zeromq-4.3.4_debug \
|
||||
${cmake_qt_parameters}
|
||||
@ -62,6 +63,10 @@ function build() {
|
||||
/opt/Qt/Tools/CMake/bin/cmake \
|
||||
--build ${build_path} \
|
||||
--target all
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
build/UnitTest/UnitTest
|
||||
}
|
||||
|
||||
function main() {
|
||||
|
Loading…
Reference in New Issue
Block a user