mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Add tests for sf::Http
This class hides a lot of its logic in the private section of the classes and uses friends to access them so there is little accessible in the public interface for testing.
This commit is contained in:
parent
364fe38956
commit
b3a467678d
@ -338,7 +338,7 @@ public:
|
||||
/// \brief Default constructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Http();
|
||||
Http() = default;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct the HTTP client with the target host
|
||||
|
@ -286,10 +286,6 @@ void Http::Response::parseFields(std::istream& in)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Http::Http() = default;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Http::Http(const std::string& host, unsigned short port)
|
||||
{
|
||||
|
@ -1,8 +1,48 @@
|
||||
#include <SFML/Network/Http.hpp>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
static_assert(!std::is_copy_constructible_v<sf::Http>);
|
||||
static_assert(!std::is_copy_assignable_v<sf::Http>);
|
||||
static_assert(!std::is_nothrow_move_constructible_v<sf::Http>);
|
||||
static_assert(!std::is_nothrow_move_assignable_v<sf::Http>);
|
||||
TEST_CASE("[Network] sf::Http")
|
||||
{
|
||||
SECTION("Type traits")
|
||||
{
|
||||
STATIC_CHECK(!std::is_copy_constructible_v<sf::Http>);
|
||||
STATIC_CHECK(!std::is_copy_assignable_v<sf::Http>);
|
||||
STATIC_CHECK(!std::is_nothrow_move_constructible_v<sf::Http>);
|
||||
STATIC_CHECK(!std::is_nothrow_move_assignable_v<sf::Http>);
|
||||
}
|
||||
|
||||
SECTION("Request")
|
||||
{
|
||||
SECTION("Type traits")
|
||||
{
|
||||
STATIC_CHECK(std::is_copy_constructible_v<sf::Http::Request>);
|
||||
STATIC_CHECK(std::is_copy_assignable_v<sf::Http::Request>);
|
||||
STATIC_CHECK(std::is_move_constructible_v<sf::Http::Request>);
|
||||
STATIC_CHECK(std::is_nothrow_move_assignable_v<sf::Http::Request>);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Response")
|
||||
{
|
||||
SECTION("Type traits")
|
||||
{
|
||||
STATIC_CHECK(std::is_copy_constructible_v<sf::Http::Response>);
|
||||
STATIC_CHECK(std::is_copy_assignable_v<sf::Http::Response>);
|
||||
STATIC_CHECK(std::is_move_constructible_v<sf::Http::Response>);
|
||||
STATIC_CHECK(std::is_nothrow_move_assignable_v<sf::Http::Response>);
|
||||
}
|
||||
|
||||
SECTION("Construction")
|
||||
{
|
||||
const sf::Http::Response response;
|
||||
CHECK(response.getField("").empty());
|
||||
CHECK(response.getStatus() == sf::Http::Response::Status::ConnectionFailed);
|
||||
CHECK(response.getMajorHttpVersion() == 0);
|
||||
CHECK(response.getMinorHttpVersion() == 0);
|
||||
CHECK(response.getBody().empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user