UnitTests/TCPTest: Don't use a random port
This commit is contained in:
parent
05e56d627d
commit
d827477de2
|
|
@ -4,24 +4,18 @@
|
||||||
#include <Nazara/Network/TcpServer.hpp>
|
#include <Nazara/Network/TcpServer.hpp>
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <random>
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
SCENARIO("TCP", "[NETWORK][TCP]")
|
SCENARIO("TCP", "[NETWORK][TCP]")
|
||||||
{
|
{
|
||||||
GIVEN("Two TCP, one client, one server")
|
GIVEN("Two TCP, one client, one server")
|
||||||
{
|
{
|
||||||
std::random_device rd;
|
|
||||||
std::uniform_int_distribution<Nz::UInt16> dis(1025, 65535);
|
|
||||||
|
|
||||||
Nz::UInt16 port = dis(rd);
|
|
||||||
|
|
||||||
Nz::TcpServer server;
|
Nz::TcpServer server;
|
||||||
server.EnableBlocking(false);
|
server.EnableBlocking(false);
|
||||||
|
|
||||||
REQUIRE(server.Listen(Nz::NetProtocol::IPv4, port) == Nz::SocketState::Bound);
|
REQUIRE(server.Listen(Nz::NetProtocol::IPv4, 0) == Nz::SocketState::Bound);
|
||||||
|
|
||||||
Nz::IpAddress serverIP(Nz::IpAddress::LoopbackIpV4.ToIPv4(), port);
|
Nz::IpAddress serverIP(Nz::IpAddress::LoopbackIpV4.ToIPv4(), server.GetBoundPort());
|
||||||
REQUIRE(serverIP.IsValid());
|
REQUIRE(serverIP.IsValid());
|
||||||
|
|
||||||
Nz::TcpClient client;
|
Nz::TcpClient client;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue