UnitTests: Choose a random port when testing
Former-commit-id: ce4e1c4b2b65327917bd0cf14b91102bfdab6327 [formerly e4390f995cb6ccb2c5e3b81a56acf0563d8d2679] [formerly a813d71a45dc17042129a31a8537b35ffaf93120 [formerly 683e75adf03f84ce2dc2454b4c22c2a20ca31668]] Former-commit-id: 65fe6b63137fc3a55439d3ec777147ab51ed259a [formerly 310169d28ca078fdf76307bbf9f0a653c3c85d42] Former-commit-id: fc03da2c66e08f6d349b5eedae057c5ab371ad9e
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
#include <Nazara/Network/UdpSocket.hpp>
|
||||
#include <Catch/catch.hpp>
|
||||
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Network/UdpSocket.hpp>
|
||||
#include <Nazara/Network/NetPacket.hpp>
|
||||
#include <Catch/catch.hpp>
|
||||
#include <random>
|
||||
|
||||
SCENARIO("UdpSocket", "[NETWORK][UDPSOCKET]")
|
||||
{
|
||||
GIVEN("Two UdpSocket, one client, one server")
|
||||
{
|
||||
Nz::UInt16 port = 64256;
|
||||
std::random_device rd;
|
||||
std::uniform_int_distribution<Nz::UInt16> dis(1025, 65535);
|
||||
|
||||
Nz::UInt16 port = dis(rd);
|
||||
Nz::UdpSocket server(Nz::NetProtocol_IPv4);
|
||||
REQUIRE(server.Bind(port) == Nz::SocketState_Bound);
|
||||
|
||||
@@ -33,6 +36,7 @@ SCENARIO("UdpSocket", "[NETWORK][UDPSOCKET]")
|
||||
Nz::NetPacket resultPacket;
|
||||
Nz::IpAddress fromIp;
|
||||
REQUIRE(server.ReceivePacket(&resultPacket, &fromIp));
|
||||
|
||||
Nz::Vector3f result;
|
||||
resultPacket >> result;
|
||||
REQUIRE(result == vector123);
|
||||
|
||||
Reference in New Issue
Block a user