Added urltest testing binary

This commit is contained in:
Thulinma 2017-07-05 02:27:47 +02:00
parent 9cc2f75a8e
commit e772168a91
2 changed files with 28 additions and 0 deletions

View file

@ -662,3 +662,7 @@ target_link_libraries(aes_ctr128
mist
)
add_test(AESTest COMMAND aes_ctr128)
add_executable(urltest ${SOURCE_DIR}/test/url.cpp)
target_link_libraries(urltest mist)
add_test(URLTest COMMAND urltest)

24
test/url.cpp Normal file
View file

@ -0,0 +1,24 @@
#include "../lib/http_parser.cpp"
#include <iostream>
int main(int argc, char ** argv){
if (argc < 2){
std::cout << "Usage: " << argv[0] << " URL" << std::endl;
return 1;
}
HTTP::URL u(argv[1]);
for (int i = 1; i < argc; ++i){
if (i > 1){
u = u.link(argv[i]);
}
std::cout << argv[i] << " -> " << u.getUrl() << std::endl;
std::cout << "Protocol: " << u.protocol << std::endl;
std::cout << "Host: " << u.host << std::endl;
std::cout << "Port: " << u.getPort() << std::endl;
std::cout << "Path: " << u.path << std::endl;
std::cout << "Query: " << u.args << std::endl;
std::cout << "Fragment: " << u.frag << std::endl;
}
return 0;
}