mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
* update tests
This commit is contained in:
parent
2ce61402bb
commit
b68f06ca83
4 changed files with 22 additions and 4 deletions
|
@ -3,11 +3,12 @@
|
|||
|
||||
using namespace i2p::http;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main() {
|
||||
HTTPReq *req;
|
||||
int ret = 0, len = 0;
|
||||
const char *buf;
|
||||
|
||||
/* test: parsing request with body */
|
||||
buf =
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: curl/7.26.0\r\n"
|
||||
|
@ -31,6 +32,7 @@ int main(int argc, char *argv[]) {
|
|||
assert(req->headers.find("User-Agent")->second == "curl/7.26.0");
|
||||
delete req;
|
||||
|
||||
/* test: parsing request without body */
|
||||
buf =
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"\r\n";
|
||||
|
@ -44,6 +46,7 @@ int main(int argc, char *argv[]) {
|
|||
assert(req->headers.size() == 0);
|
||||
delete req;
|
||||
|
||||
/* test: parsing request without body */
|
||||
buf =
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"\r\n";
|
||||
|
@ -52,6 +55,7 @@ int main(int argc, char *argv[]) {
|
|||
assert((ret = req->parse(buf, len)) == -1); /* no host header */
|
||||
delete req;
|
||||
|
||||
/* test: parsing incomplete request */
|
||||
buf =
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"";
|
||||
|
@ -60,6 +64,7 @@ int main(int argc, char *argv[]) {
|
|||
assert((ret = req->parse(buf, len)) == 0); /* request not completed */
|
||||
delete req;
|
||||
|
||||
/* test: parsing slightly malformed request */
|
||||
buf =
|
||||
"GET http://inr.i2p HTTP/1.1\r\n"
|
||||
"Host: stats.i2p\r\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue