Convert all remaining enums to enum classes (!)

This commit is contained in:
Jérôme Leclercq
2021-05-25 00:08:50 +02:00
parent 8cdd0b51cb
commit 874fb3542e
122 changed files with 1082 additions and 2169 deletions

View File

@@ -9,7 +9,7 @@ SCENARIO("AbstractHash", "[CORE][ABSTRACTHASH]")
{
GIVEN("The hash SHA512")
{
std::unique_ptr<Nz::AbstractHash> SHA512 = Nz::AbstractHash::Get(Nz::HashType_SHA512);
std::unique_ptr<Nz::AbstractHash> SHA512 = Nz::AbstractHash::Get(Nz::HashType::SHA512);
SHA512->Begin();
WHEN("We introduce data")

View File

@@ -32,61 +32,61 @@ TEST_CASE("ComputeHash", "[CORE][ALGORITHM]")
{
/*SECTION("Compute CRC32 of '1234'")
{
auto result = Nz::ComputeHash(Nz::HashType_CRC32, "1234");
auto result = Nz::ComputeHash(Nz::HashType::CRC32, "1234");
REQUIRE(Nz::ToUpper(result.ToHex()) == "596A3B55");
}
SECTION("Compute CRC64 of '1234'")
{
auto result = Nz::ComputeHash(Nz::HashType_CRC64, "1234");
auto result = Nz::ComputeHash(Nz::HashType::CRC64, "1234");
REQUIRE(Nz::ToUpper(result.ToHex()) == "33302B9FC23855A8");
}
SECTION("Compute Fletcher16 of '1234'")
{
auto result = Nz::ComputeHash(Nz::HashType_Fletcher16, "1234");
auto result = Nz::ComputeHash(Nz::HashType::Fletcher16, "1234");
REQUIRE(Nz::ToUpper(result.ToHex()) == "F5CA");
}*/
SECTION("Compute MD5 of '1234'")
{
auto result = Nz::ComputeHash(Nz::HashType_MD5, "1234");
auto result = Nz::ComputeHash(Nz::HashType::MD5, "1234");
REQUIRE(Nz::ToUpper(result.ToHex()) == "81DC9BDB52D04DC20036DBD8313ED055");
}
SECTION("Compute SHA1 of '1234'")
{
auto result = Nz::ComputeHash(Nz::HashType_SHA1, "1234");
auto result = Nz::ComputeHash(Nz::HashType::SHA1, "1234");
REQUIRE(Nz::ToUpper(result.ToHex()) == "7110EDA4D09E062AA5E4A390B0A572AC0D2C0220");
}
SECTION("Compute SHA224 of '1234'")
{
auto result = Nz::ComputeHash(Nz::HashType_SHA224, "1234");
auto result = Nz::ComputeHash(Nz::HashType::SHA224, "1234");
REQUIRE(Nz::ToUpper(result.ToHex()) == "99FB2F48C6AF4761F904FC85F95EB56190E5D40B1F44EC3A9C1FA319");
}
SECTION("Compute SHA256 of '1234'")
{
auto result = Nz::ComputeHash(Nz::HashType_SHA256, "1234");
auto result = Nz::ComputeHash(Nz::HashType::SHA256, "1234");
REQUIRE(Nz::ToUpper(result.ToHex()) == "03AC674216F3E15C761EE1A5E255F067953623C8B388B4459E13F978D7C846F4");
}
SECTION("Compute SHA384 of '1234'")
{
auto result = Nz::ComputeHash(Nz::HashType_SHA384, "1234");
auto result = Nz::ComputeHash(Nz::HashType::SHA384, "1234");
REQUIRE(Nz::ToUpper(result.ToHex()) == "504F008C8FCF8B2ED5DFCDE752FC5464AB8BA064215D9C5B5FC486AF3D9AB8C81B14785180D2AD7CEE1AB792AD44798C");
}
SECTION("Compute SHA512 of '1234'")
{
auto result = Nz::ComputeHash(Nz::HashType_SHA512, "1234");
auto result = Nz::ComputeHash(Nz::HashType::SHA512, "1234");
REQUIRE(Nz::ToUpper(result.ToHex()) == "D404559F602EAB6FD602AC7680DACBFAADD13630335E951F097AF3900E9DE176B6DB28512F2E000B9D04FBA5133E8B1C6E8DF59DB3A8AB9D60BE4B97CC9E81DB");
}
SECTION("Compute Whirlpool of '1234'")
{
auto result = Nz::ComputeHash(Nz::HashType_Whirlpool, "1234");
auto result = Nz::ComputeHash(Nz::HashType::Whirlpool, "1234");
REQUIRE(Nz::ToUpper(result.ToHex()) == "2F9959B230A44678DD2DC29F037BA1159F233AA9AB183CE3A0678EAAE002E5AA6F27F47144A1A4365116D3DB1B58EC47896623B92D85CB2F191705DAF11858B8");
}
}

View File

@@ -44,7 +44,7 @@ SCENARIO("ByteStream", "[CORE][BYTESTREAM]")
Nz::ByteArray byteArray(numberOfBytes);
Nz::ByteStream byteStream(&byteArray);
byteStream.SetDataEndianness(Nz::GetPlatformEndianness() == Nz::Endianness_BigEndian ? Nz::Endianness_LittleEndian : Nz::Endianness_BigEndian);
byteStream.SetDataEndianness(Nz::GetPlatformEndianness() == Nz::Endianness::BigEndian ? Nz::Endianness::LittleEndian : Nz::Endianness::BigEndian);
WHEN("We write an integer")
{

View File

@@ -3,7 +3,7 @@
SCENARIO("Error", "[CORE][ERROR]")
{
Nz::UInt32 oldFlags = Nz::Error::GetFlags();
Nz::ErrorModeFlags oldFlags = Nz::Error::GetFlags();
GIVEN("Multiple errors")
{
@@ -11,15 +11,15 @@ SCENARIO("Error", "[CORE][ERROR]")
{
THEN("These errors should be written in the log file")
{
Nz::Error::Trigger(Nz::ErrorType_Internal, "ErrorType_Internal");
Nz::Error::Trigger(Nz::ErrorType_Internal, "ErrorType_Internal", 2, "Error.cpp", "2nd place Internal");
REQUIRE("ErrorType_Internal" == Nz::Error::GetLastError());
Nz::Error::Trigger(Nz::ErrorType_Normal, "ErrorType_Normal");
Nz::Error::Trigger(Nz::ErrorType_Normal, "ErrorType_Normal", 2, "Error.cpp", "2nd place Normal");
REQUIRE("ErrorType_Normal" == Nz::Error::GetLastError());
Nz::Error::Trigger(Nz::ErrorType_Warning, "ErrorType_Warning");
Nz::Error::Trigger(Nz::ErrorType_Warning, "ErrorType_Warning", 2, "Error.cpp", "2nd place Warning");
REQUIRE("ErrorType_Warning" == Nz::Error::GetLastError());
Nz::Error::Trigger(Nz::ErrorType::Internal, "ErrorType::Internal");
Nz::Error::Trigger(Nz::ErrorType::Internal, "ErrorType::Internal", 2, "Error.cpp", "2nd place Internal");
REQUIRE("ErrorType::Internal" == Nz::Error::GetLastError());
Nz::Error::Trigger(Nz::ErrorType::Normal, "ErrorType::Normal");
Nz::Error::Trigger(Nz::ErrorType::Normal, "ErrorType::Normal", 2, "Error.cpp", "2nd place Normal");
REQUIRE("ErrorType::Normal" == Nz::Error::GetLastError());
Nz::Error::Trigger(Nz::ErrorType::Warning, "ErrorType::Warning");
Nz::Error::Trigger(Nz::ErrorType::Warning, "ErrorType::Warning", 2, "Error.cpp", "2nd place Warning");
REQUIRE("ErrorType::Warning" == Nz::Error::GetLastError());
}
}
}

View File

@@ -67,7 +67,7 @@ SCENARIO("File", "[CORE][FILE]")
{
REQUIRE(std::filesystem::exists(GetResourceDir() / "Engine/Core/FileTest.txt"));
Nz::File fileTest(GetResourceDir() / "Engine/Core/FileTest.txt", Nz::OpenMode_ReadOnly | Nz::OpenMode_Text);
Nz::File fileTest(GetResourceDir() / "Engine/Core/FileTest.txt", Nz::OpenMode::ReadOnly | Nz::OpenMode::Text);
WHEN("We read the first line of the file")
{

View File

@@ -25,19 +25,19 @@ SCENARIO("PrimitiveList", "[CORE][PRIMITIVELIST]")
THEN("The first one is the cubic sphere")
{
REQUIRE(primitiveList(0).type == Nz::PrimitiveType_Sphere);
REQUIRE(primitiveList(0).sphere.type == Nz::SphereType_Cubic);
REQUIRE(primitiveList(0).type == Nz::PrimitiveType::Sphere);
REQUIRE(primitiveList(0).sphere.type == Nz::SphereType::Cubic);
}
THEN("The second one is the box")
{
REQUIRE(primitiveList(1).type == Nz::PrimitiveType_Box);
REQUIRE(primitiveList(1).type == Nz::PrimitiveType::Box);
}
THEN("The third one is the ico sphere")
{
REQUIRE(primitiveList(2).type == Nz::PrimitiveType_Sphere);
REQUIRE(primitiveList(2).sphere.type == Nz::SphereType_Ico);
REQUIRE(primitiveList(2).type == Nz::PrimitiveType::Sphere);
REQUIRE(primitiveList(2).sphere.type == Nz::SphereType::Ico);
}
}
}

View File

@@ -27,7 +27,7 @@ SCENARIO("IpAddress", "[NETWORK][IPADDRESS]")
{
WHEN("We get the IP of Nazara")
{
std::vector<Nz::HostnameInfo> hostnameInfos = Nz::IpAddress::ResolveHostname(Nz::NetProtocol_IPv4, "nazara.digitalpulsesoftware.net");
std::vector<Nz::HostnameInfo> hostnameInfos = Nz::IpAddress::ResolveHostname(Nz::NetProtocol::IPv4, "nazara.digitalpulsesoftware.net");
THEN("Result is not null")
{

View File

@@ -1,47 +0,0 @@
#include <Nazara/Network/RUdpConnection.hpp>
#include <Catch/catch.hpp>
#include <Nazara/Math/Vector3.hpp>
SCENARIO("RUdpConnection", "[NETWORK][RUDPCONNECTION]")
{
GIVEN("Two RUdpConnection, one client, one server")
{
// Disabled for now
/*Nz::UInt16 port = 64266;
Nz::RUdpConnection server;
REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port));
Nz::IpAddress serverIP(Nz::IpAddress::LoopbackIpV4.ToIPv4(), port);
REQUIRE(serverIP.IsValid());
Nz::RUdpConnection client;
REQUIRE(client.Listen(Nz::NetProtocol_IPv4, port + 1));
Nz::IpAddress clientIP = client.GetBoundAddress();
REQUIRE(client.Connect(serverIP));
REQUIRE(clientIP.IsValid());
WHEN("We send data from client")
{
Nz::NetPacket packet(1);
Nz::Vector3f vector123(1.f, 2.f, 3.f);
packet << vector123;
REQUIRE(client.Send(serverIP, Nz::PacketPriority_Immediate, Nz::PacketReliability_Reliable, packet));
client.Update();
THEN("We should get it on the server")
{
Nz::RUdpMessage rudpMessage;
server.Update();
REQUIRE(server.PollMessage(&rudpMessage));
Nz::Vector3f result;
rudpMessage.data >> result;
REQUIRE(result == vector123);
}
}*/
}
}

View File

@@ -17,7 +17,7 @@ SCENARIO("SocketPoller", "[NETWORK][SOCKETPOLLER]")
Nz::TcpServer server;
server.EnableBlocking(false);
REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port) == Nz::SocketState_Bound);
REQUIRE(server.Listen(Nz::NetProtocol::IPv4, port) == Nz::SocketState::Bound);
Nz::IpAddress serverIP(Nz::IpAddress::LoopbackIpV4.ToIPv4(), port);
REQUIRE(serverIP.IsValid());
@@ -27,7 +27,7 @@ SCENARIO("SocketPoller", "[NETWORK][SOCKETPOLLER]")
WHEN("We register the server socket to the poller")
{
REQUIRE(serverPoller.RegisterSocket(server, Nz::SocketPollEvent_Read));
REQUIRE(serverPoller.RegisterSocket(server, Nz::SocketPollEvent::Read));
THEN("The poller should have registered our socket")
{
@@ -37,7 +37,7 @@ SCENARIO("SocketPoller", "[NETWORK][SOCKETPOLLER]")
{
Nz::SocketState state = clientToServer.Connect(serverIP);
CHECK(state != Nz::SocketState_NotConnected);
CHECK(state != Nz::SocketState::NotConnected);
AND_THEN("We wait on our selector, it should return true")
{
@@ -48,7 +48,7 @@ SCENARIO("SocketPoller", "[NETWORK][SOCKETPOLLER]")
WHEN("We register the client socket to the poller")
{
REQUIRE(serverPoller.RegisterSocket(serverToClient, Nz::SocketPollEvent_Read));
REQUIRE(serverPoller.RegisterSocket(serverToClient, Nz::SocketPollEvent::Read));
THEN("The poller should have registered our socket")
{

View File

@@ -19,13 +19,13 @@ SCENARIO("TCP", "[NETWORK][TCP]")
Nz::TcpServer server;
server.EnableBlocking(false);
REQUIRE(server.Listen(Nz::NetProtocol_IPv4, port) == Nz::SocketState_Bound);
REQUIRE(server.Listen(Nz::NetProtocol::IPv4, port) == Nz::SocketState::Bound);
Nz::IpAddress serverIP(Nz::IpAddress::LoopbackIpV4.ToIPv4(), port);
REQUIRE(serverIP.IsValid());
Nz::TcpClient client;
REQUIRE(client.Connect(serverIP) == Nz::SocketState_Connecting);
REQUIRE(client.Connect(serverIP) == Nz::SocketState::Connecting);
Nz::IpAddress clientIP = client.GetRemoteAddress();
CHECK(clientIP.IsValid());

View File

@@ -12,14 +12,14 @@ SCENARIO("UdpSocket", "[NETWORK][UDPSOCKET]")
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);
Nz::UdpSocket server(Nz::NetProtocol::IPv4);
REQUIRE(server.Bind(port) == Nz::SocketState::Bound);
Nz::IpAddress serverIP(Nz::IpAddress::LoopbackIpV4.ToIPv4(), port);
REQUIRE(serverIP.IsValid());
Nz::UdpSocket client(Nz::NetProtocol_IPv4);
REQUIRE(client.Bind(port + 1) == Nz::SocketState_Bound);
Nz::UdpSocket client(Nz::NetProtocol::IPv4);
REQUIRE(client.Bind(port + 1) == Nz::SocketState::Bound);
Nz::IpAddress clientIP = client.GetBoundAddress();
REQUIRE(clientIP.IsValid());

View File

@@ -131,7 +131,7 @@ SCENARIO("RigidBody2D", "[PHYSICS2D][RIGIDBODY2D]")
{
CHECK(body.GetAABB() == aabb);
CHECK(body.GetAngularVelocity() == 0.f);
CHECK(body.GetMassCenter(Nz::CoordSys_Global) == position);
CHECK(body.GetMassCenter(Nz::CoordSys::Global) == position);
CHECK(body.GetGeom() == box);
CHECK(body.GetMass() == Approx(mass));
CHECK(body.GetPosition() == position);
@@ -155,7 +155,7 @@ SCENARIO("RigidBody2D", "[PHYSICS2D][RIGIDBODY2D]")
{
aabb.Translate(velocity);
CHECK(body.GetAABB() == aabb);
CHECK(body.GetMassCenter(Nz::CoordSys_Global) == position);
CHECK(body.GetMassCenter(Nz::CoordSys::Global) == position);
CHECK(body.GetPosition() == position);
CHECK(body.GetVelocity() == velocity);
}