frnetlib/tests/SocketTest.cpp
Fred Nicolson c8e03f2df8 Added more tests. Tweaks.
Receiving an http request/response will now return errors like HttpHeaderTooBig, instead of the type being set to that.

Added fr::Socket::status_to_string for converting status values into English strings.
2017-09-25 16:19:47 +01:00

32 lines
765 B
C++

//
// Created by fred.nicolson on 25/09/17.
//
#include <gtest/gtest.h>
#include <frnetlib/Socket.h>
TEST(SocketTest, status_to_string_valid)
{
ASSERT_EQ(fr::Socket::status_to_string(fr::Socket::Status::Unknown), "Unknown");
ASSERT_EQ(fr::Socket::status_to_string(fr::Socket::Status::HttpBodyTooBig), "HTTP body too big");
}
TEST(SocketTest, status_to_string_invalid)
{
try
{
auto str = fr::Socket::status_to_string(static_cast<fr::Socket::Status>(-1));
}
catch(const std::logic_error &)
{
try
{
auto str = fr::Socket::status_to_string(static_cast<fr::Socket::Status>(99999));
}
catch(const std::logic_error &)
{
return;
}
}
ASSERT_TRUE(false);
}