2019-09-10 02:34:36 +02:00
|
|
|
/*
|
|
|
|
* IXHttpTest.cpp
|
|
|
|
* Author: Benjamin Sergeant
|
|
|
|
* Copyright (c) 2019 Machine Zone. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-09-23 19:25:23 +02:00
|
|
|
#include "catch.hpp"
|
2019-09-10 02:34:36 +02:00
|
|
|
#include <iostream>
|
|
|
|
#include <ixwebsocket/IXHttp.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
namespace ix
|
|
|
|
{
|
2019-09-23 19:25:23 +02:00
|
|
|
TEST_CASE("http", "[http]")
|
2019-09-10 02:34:36 +02:00
|
|
|
{
|
2019-09-23 19:25:23 +02:00
|
|
|
SECTION("Normal case")
|
|
|
|
{
|
|
|
|
std::string line = "HTTP/1.1 200";
|
|
|
|
auto result = Http::parseStatusLine(line);
|
|
|
|
|
|
|
|
REQUIRE(result.first == "HTTP/1.1");
|
|
|
|
REQUIRE(result.second == 200);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("http/1.0 case")
|
|
|
|
{
|
|
|
|
std::string line = "HTTP/1.0 200";
|
|
|
|
auto result = Http::parseStatusLine(line);
|
|
|
|
|
|
|
|
REQUIRE(result.first == "HTTP/1.0");
|
|
|
|
REQUIRE(result.second == 200);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("empty case")
|
|
|
|
{
|
|
|
|
std::string line = "";
|
|
|
|
auto result = Http::parseStatusLine(line);
|
|
|
|
|
|
|
|
REQUIRE(result.first == "");
|
|
|
|
REQUIRE(result.second == -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("empty case")
|
|
|
|
{
|
|
|
|
std::string line = "HTTP/1.1";
|
|
|
|
auto result = Http::parseStatusLine(line);
|
|
|
|
|
|
|
|
REQUIRE(result.first == "HTTP/1.1");
|
|
|
|
REQUIRE(result.second == -1);
|
|
|
|
}
|
2019-09-10 02:34:36 +02:00
|
|
|
}
|
|
|
|
|
2019-09-23 19:25:23 +02:00
|
|
|
} // namespace ix
|