Converted Marco's URL library unit tests to Meson

Change-Id: Ia8941968b75c7d8259c630e7e0121dc27d3a4373
This commit is contained in:
Katri 2023-01-16 15:36:28 +00:00 committed by Thulinma
parent 211d9eac30
commit 90321887cc
2 changed files with 115 additions and 1 deletions

View file

@ -1,4 +1,5 @@
#include "../lib/http_parser.cpp"
#include <cassert>
#include <iostream>
int main(int argc, char **argv){
@ -20,6 +21,22 @@ int main(int argc, char **argv){
std::cout << "Username: " << u.user << std::endl;
std::cout << "Password: " << u.pass << std::endl;
std::cout << std::endl;
assert(u.protocol == std::getenv("Protocol"));
assert(u.host == std::getenv("Host"));
std::string ulocal;
Socket::isLocalhost(u.host) ? ulocal = "Yes" : ulocal = "No";
assert(ulocal == std::getenv("Local"));
uint16_t uport = 0;
std::stringstream ss(std::getenv("Port"));
ss >> uport;
assert(u.getPort() == uport);
assert(u.path == std::getenv("Path"));
assert(u.args == std::getenv("Query"));
assert(u.frag == std::getenv("Fragment"));
assert(u.user == std::getenv("Username"));
assert(u.pass == std::getenv("Password"));
}
return 0;
}