Merge pull request #57 from Gawaboumga/linux-compilation-merge
Linux compilation merge Former-commit-id: 36205a0bb6c84b55e7af1323aa041fc10f49f894
This commit is contained in:
commit
f4f799baa1
|
|
@ -11,6 +11,7 @@
|
|||
#include <NDK/World.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Utility/Window.hpp>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
namespace Ndk
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ namespace Ndk
|
|||
s_application = nullptr;
|
||||
}
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
template<typename T, typename... Args>
|
||||
T& Application::AddWindow(Args&&... args)
|
||||
{
|
||||
|
|
@ -46,6 +47,7 @@ namespace Ndk
|
|||
m_windows.emplace_back(new T(std::forward<Args>(args)...));
|
||||
return static_cast<T&>(*m_windows.back().get());
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename... Args>
|
||||
World& Application::AddWorld(Args&&... args)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <Ndk/BaseComponent.hpp>
|
||||
#include <NDK/BaseComponent.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
|
||||
namespace Ndk
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ namespace Ndk
|
|||
application.SetMethod("Quit", &Application::Quit);
|
||||
|
||||
/*********************************** Ndk::Console **********************************/
|
||||
#ifndef NDK_SERVER
|
||||
consoleClass.Inherit<Nz::Node>(nodeClass, [] (ConsoleHandle* handle) -> Nz::Node*
|
||||
{
|
||||
return handle->GetObject();
|
||||
|
|
@ -84,6 +85,7 @@ namespace Ndk
|
|||
//consoleClass.SetMethod("SetTextFont", &Console::SetTextFont);
|
||||
|
||||
consoleClass.SetMethod("Show", &Console::Show, true);
|
||||
#endif
|
||||
|
||||
/*********************************** Ndk::Entity **********************************/
|
||||
entityClass.SetMethod("Enable", &Entity::Enable);
|
||||
|
|
@ -248,4 +250,4 @@ namespace Ndk
|
|||
}
|
||||
instance.SetGlobal("ComponentType");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace Ndk
|
||||
{
|
||||
World::~World()
|
||||
World::~World() noexcept
|
||||
{
|
||||
// La destruction doit se faire dans un ordre précis
|
||||
Clear();
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ namespace Nz
|
|||
static bool OpenDevice();
|
||||
static OpenALFunc LoadEntry(const char* name, bool throwException = false);
|
||||
};
|
||||
}
|
||||
|
||||
// al
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALBUFFER3F alBuffer3f;
|
||||
|
|
@ -186,6 +185,8 @@ NAZARA_AUDIO_API extern OpenALDetail::LPALCOPENDEVICE alcOpenDevice;
|
|||
NAZARA_AUDIO_API extern OpenALDetail::LPALCPROCESSCONTEXT alcProcessContext;
|
||||
NAZARA_AUDIO_API extern OpenALDetail::LPALCSUSPENDCONTEXT alcSuspendContext;
|
||||
|
||||
}
|
||||
|
||||
#endif // NAZARA_AUDIO_OPENAL
|
||||
|
||||
#endif // NAZARA_OPENAL_HPP
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ namespace Nz
|
|||
friend Type;
|
||||
|
||||
public:
|
||||
using ExtensionGetter = bool (*)(const String& extension);
|
||||
using FormatQuerier = bool (*)(const String& format);
|
||||
using FileSaver = bool (*)(const Type& resource, const String& filePath, const Parameters& parameters);
|
||||
using StreamSaver = bool (*)(const Type& resource, const String& format, Stream& stream, const Parameters& parameters);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Nz
|
|||
{
|
||||
for (Saver& saver : Type::s_savers)
|
||||
{
|
||||
ExtensionGetter isExtensionSupported = std::get<0>(loader);
|
||||
ExtensionGetter isExtensionSupported = std::get<0>(saver);
|
||||
|
||||
if (isExtensionSupported && isExtensionSupported(extension))
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Nz
|
|||
SkyboxBackground(TextureRef cubemapTexture = TextureRef());
|
||||
~SkyboxBackground() = default;
|
||||
|
||||
void Draw(const AbstractViewer* viewer) const;
|
||||
void Draw(const AbstractViewer* viewer) const override;
|
||||
|
||||
BackgroundType GetBackgroundType() const override;
|
||||
inline const Vector3f& GetMovementOffset() const;
|
||||
|
|
|
|||
|
|
@ -636,7 +636,7 @@ namespace Nz
|
|||
if (extend > Extend_Max)
|
||||
return false;
|
||||
|
||||
boundingVolume->extend = extend;
|
||||
boundingVolume->extend = static_cast<Extend>(extend);
|
||||
|
||||
if (!Unserialize(context, &boundingVolume->aabb))
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,11 @@ namespace Nz
|
|||
|
||||
String ToString() const;
|
||||
|
||||
template<typename U>
|
||||
friend bool Serialize(SerializationContext& context, const Frustum<U>& frustum);
|
||||
template<typename U>
|
||||
friend bool Unserialize(SerializationContext& context, Frustum<U>* frustum);
|
||||
|
||||
private:
|
||||
Vector3<T> m_corners[BoxCorner_Max+1];
|
||||
Plane<T> m_planes[FrustumPlane_Max+1];
|
||||
|
|
@ -62,9 +67,6 @@ namespace Nz
|
|||
|
||||
typedef Frustum<double> Frustumd;
|
||||
typedef Frustum<float> Frustumf;
|
||||
|
||||
template<typename T> bool Serialize(SerializationContext& context, const Frustum<T>& frustum);
|
||||
template<typename T> bool Unserialize(SerializationContext& context, Frustum<T>* frustum);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -688,13 +688,13 @@ namespace Nz
|
|||
{
|
||||
for (unsigned int i = 0; i <= BoxCorner_Max; ++i)
|
||||
{
|
||||
if (!Serialize(context, m_corners[i]))
|
||||
if (!Serialize(context, frustum.m_corners[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i <= FrustumPlane_Max; ++i)
|
||||
{
|
||||
if (!Serialize(context, m_planes[i]))
|
||||
if (!Serialize(context, frustum.m_planes[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -702,24 +702,24 @@ namespace Nz
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Matrix4
|
||||
* \brief Unserializes a Frustum
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param matrix Output matrix
|
||||
* \param matrix Output frustum
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Frustum<T>* frustum)
|
||||
{
|
||||
for (unsigned int i = 0; i <= BoxCorner_Max; ++i)
|
||||
{
|
||||
if (!Unserialize(context, &m_corners[i]))
|
||||
if (!Unserialize(context, &frustum->m_corners[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i <= FrustumPlane_Max; ++i)
|
||||
{
|
||||
if (!Unserialize(context, &m_planes[i]))
|
||||
if (!Unserialize(context, &frustum->m_planes[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1792,9 +1792,10 @@ namespace Nz
|
|||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Matrix4<T>* matrix)
|
||||
{
|
||||
T* head = matrix->operator T*();
|
||||
for (unsigned int i = 0; i < 16; ++i)
|
||||
{
|
||||
if (!Unserialize(context, &matrix[i]))
|
||||
if (!Unserialize(context, head + i))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,6 +119,10 @@ namespace Nz
|
|||
|
||||
struct PeerData //TODO: Move this to RUdpClient
|
||||
{
|
||||
PeerData() = default;
|
||||
PeerData(PeerData&& other) = default;
|
||||
PeerData& operator=(PeerData&& other) = default;
|
||||
|
||||
std::array<std::vector<PendingPacket>, PacketPriority_Max + 1> pendingPackets;
|
||||
std::deque<PendingAckPacket> pendingAckQueue;
|
||||
std::set<UInt16> receivedQueue;
|
||||
|
|
@ -153,6 +157,6 @@ namespace Nz
|
|||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Network/RudpConnection.inl>
|
||||
#include <Nazara/Network/RUdpConnection.inl>
|
||||
|
||||
#endif // NAZARA_RUDPSERVER_HPP
|
||||
#endif // NAZARA_RUDPSERVER_HPP
|
||||
|
|
|
|||
|
|
@ -153,7 +153,6 @@ namespace Nz
|
|||
static void OnContextChanged(const Context* newContext);
|
||||
static void OnContextDestruction(const Context* context);
|
||||
};
|
||||
}
|
||||
|
||||
NAZARA_RENDERER_API extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
NAZARA_RENDERER_API extern PFNGLATTACHSHADERPROC glAttachShader;
|
||||
|
|
@ -336,6 +335,8 @@ NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapInter
|
|||
NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif // NAZARA_RENDERER_OPENGL
|
||||
|
||||
#endif // NAZARA_OPENGL_HPP
|
||||
|
|
|
|||
|
|
@ -372,7 +372,6 @@ namespace Nz
|
|||
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
// al
|
||||
OpenALDetail::LPALBUFFER3F alBuffer3f = nullptr;
|
||||
|
|
@ -470,3 +469,5 @@ OpenALDetail::LPALCMAKECONTEXTCURRENT alcMakeContextCurrent = nullptr;
|
|||
OpenALDetail::LPALCOPENDEVICE alcOpenDevice = nullptr;
|
||||
OpenALDetail::LPALCPROCESSCONTEXT alcProcessContext = nullptr;
|
||||
OpenALDetail::LPALCSUSPENDCONTEXT alcSuspendContext = nullptr;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace Nz
|
|||
return true;
|
||||
else
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
if (errno == EBADF || errno == EOVERFLOW)
|
||||
NazaraError("Unable to get next result: " + Error::GetLastSystemError());
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@ namespace Nz
|
|||
int flags;
|
||||
mode_t permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
|
||||
if (mode & OpenMode_ReadWrite)
|
||||
if ((mode & OpenMode_ReadWrite) == OpenMode_ReadWrite)
|
||||
flags = O_CREAT | O_RDWR;
|
||||
else if (mode & OpenMode_ReadOnly)
|
||||
else if ((mode & OpenMode_ReadOnly) == OpenMode_ReadOnly)
|
||||
flags = O_RDONLY;
|
||||
else if (mode & OpenMode_WriteOnly)
|
||||
else if ((mode & OpenMode_WriteOnly) == OpenMode_WriteOnly)
|
||||
flags = O_CREAT | O_WRONLY;
|
||||
else
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -3204,14 +3204,12 @@ namespace Nz
|
|||
EnsureOwnership(true);
|
||||
|
||||
m_sharedString->size = 1;
|
||||
m_sharedString->string[0] = character;
|
||||
m_sharedString->string[1] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
auto newString = std::make_shared<SharedString>(1);
|
||||
newString->string[0] = character;
|
||||
}
|
||||
m_sharedString = std::make_shared<SharedString>(1);
|
||||
|
||||
m_sharedString->string[0] = character;
|
||||
}
|
||||
else
|
||||
ReleaseString();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Network/RudpConnection.hpp>
|
||||
#include <Nazara/Network/RUdpConnection.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Network/NetPacket.hpp>
|
||||
|
|
@ -474,7 +474,7 @@ namespace Nz
|
|||
return true;
|
||||
}
|
||||
|
||||
inline void RUdpConnection::Uninitialize()
|
||||
void RUdpConnection::Uninitialize()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2078,7 +2078,6 @@ namespace Nz
|
|||
};
|
||||
|
||||
static_assert(VertexComponent_Max + 1 == 16, "Attribute index array is incomplete");
|
||||
}
|
||||
|
||||
PFNGLACTIVETEXTUREPROC glActiveTexture = nullptr;
|
||||
PFNGLATTACHSHADERPROC glAttachShader = nullptr;
|
||||
|
|
@ -2260,3 +2259,5 @@ GLX::PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr;
|
|||
GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapIntervalMESA = nullptr;
|
||||
GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ SCENARIO("File", "[CORE][FILE]")
|
|||
{
|
||||
Nz::File file("Test File.txt", Nz::OpenMode_ReadWrite);
|
||||
REQUIRE(file.GetDirectory() == Nz::Directory::GetCurrent() + NAZARA_DIRECTORY_SEPARATOR);
|
||||
CHECK(file.IsOpen());
|
||||
REQUIRE(file.IsOpen());
|
||||
|
||||
THEN("We are allowed to write 3 times 'Test String'")
|
||||
{
|
||||
|
|
@ -50,4 +50,38 @@ SCENARIO("File", "[CORE][FILE]")
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("The test file")
|
||||
{
|
||||
REQUIRE(Nz::File::Exists("resources/Engine/Core/FileTest.txt"));
|
||||
|
||||
Nz::File fileTest("resources/Engine/Core/FileTest.txt", Nz::OpenMode_ReadOnly | Nz::OpenMode_Text);
|
||||
|
||||
WHEN("We read the first line of the file")
|
||||
{
|
||||
REQUIRE(fileTest.IsOpen());
|
||||
Nz::String content = fileTest.ReadLine();
|
||||
|
||||
THEN("The content must be 'Test'")
|
||||
{
|
||||
REQUIRE(content == "Test");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("Nothing")
|
||||
{
|
||||
WHEN("We get the absolute path of something containing relative path")
|
||||
{
|
||||
Nz::String containingDot = "/resources/Spaceship/./spaceship.mtl";
|
||||
Nz::String containingDoubleDot = "/resources/Spaceship/../Spaceship/spaceship.mtl";
|
||||
|
||||
THEN("The relative positioning should disappear")
|
||||
{
|
||||
Nz::String containingNoMoreDot = "/resources/Spaceship/spaceship.mtl";
|
||||
REQUIRE(Nz::File::AbsolutePath(containingDot) == containingNoMoreDot);
|
||||
REQUIRE(Nz::File::AbsolutePath(containingDoubleDot) == containingNoMoreDot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,261 @@
|
|||
#include <Nazara/Core/Serialization.hpp>
|
||||
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/MemoryView.hpp>
|
||||
#include <Nazara/Math/BoundingVolume.hpp>
|
||||
#include <Nazara/Math/Frustum.hpp>
|
||||
#include <Nazara/Math/Ray.hpp>
|
||||
|
||||
#include <Catch/catch.hpp>
|
||||
|
||||
SCENARIO("Serialization", "[CORE][SERIALIZATION]")
|
||||
{
|
||||
GIVEN("A context of serialization")
|
||||
{
|
||||
std::array<char, 256> datas; // The array must be bigger than any of the serializable classes
|
||||
Nz::MemoryView stream(datas.data(), datas.size());
|
||||
|
||||
Nz::SerializationContext context;
|
||||
context.stream = &stream;
|
||||
|
||||
WHEN("We serialize basic types")
|
||||
{
|
||||
THEN("Arithmetical types")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Serialize(context, 3));
|
||||
int value = 0;
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &value));
|
||||
REQUIRE(value == 3);
|
||||
}
|
||||
|
||||
THEN("Boolean type")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Serialize(context, true));
|
||||
context.stream->SetCursorPos(0);
|
||||
bool value = false;
|
||||
REQUIRE(Unserialize(context, &value));
|
||||
REQUIRE(value == true);
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("We serialize mathematical classes")
|
||||
{
|
||||
THEN("BoudingVolume")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::BoundingVolumef nullVolume = Nz::BoundingVolumef::Null();
|
||||
Nz::BoundingVolumef copy(nullVolume);
|
||||
REQUIRE(Serialize(context, nullVolume));
|
||||
nullVolume = Nz::BoundingVolumef::Infinite();
|
||||
REQUIRE(nullVolume != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &nullVolume));
|
||||
REQUIRE(nullVolume == copy);
|
||||
}
|
||||
|
||||
THEN("Box")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::Boxf zeroBox = Nz::Boxf::Zero();
|
||||
Nz::Boxf copy(zeroBox);
|
||||
REQUIRE(Serialize(context, zeroBox));
|
||||
zeroBox = Nz::Boxf(1, 1, 1, 1, 1, 1);
|
||||
REQUIRE(zeroBox != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &zeroBox));
|
||||
REQUIRE(zeroBox == copy);
|
||||
}
|
||||
|
||||
THEN("EulerAngles")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::EulerAnglesf zeroEuler = Nz::EulerAnglesf::Zero();
|
||||
Nz::EulerAnglesf copy(zeroEuler);
|
||||
REQUIRE(Serialize(context, zeroEuler));
|
||||
zeroEuler = Nz::EulerAnglesf(10, 24, 6); // Random values
|
||||
REQUIRE(zeroEuler != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &zeroEuler));
|
||||
REQUIRE(zeroEuler == copy);
|
||||
}
|
||||
|
||||
THEN("Frustum")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::Frustumf frustum;
|
||||
frustum.Build(10, 10, 10, 100, Nz::Vector3f::UnitX(), Nz::Vector3f::UnitZ()); // Random values
|
||||
Nz::Frustumf copy(frustum);
|
||||
REQUIRE(Serialize(context, frustum));
|
||||
frustum.Build(50, 40, 20, 100, Nz::Vector3f::UnitX(), Nz::Vector3f::UnitZ());
|
||||
for (unsigned int i = 0; i <= Nz::BoxCorner_Max; ++i)
|
||||
REQUIRE(frustum.GetCorner(static_cast<Nz::BoxCorner>(i)) != copy.GetCorner(static_cast<Nz::BoxCorner>(i)));
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &frustum));
|
||||
for (unsigned int i = 0; i <= Nz::BoxCorner_Max; ++i)
|
||||
REQUIRE(frustum.GetCorner(static_cast<Nz::BoxCorner>(i)) == copy.GetCorner(static_cast<Nz::BoxCorner>(i)));
|
||||
}
|
||||
|
||||
THEN("Matrix4")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::Matrix4f zeroMatrix = Nz::Matrix4f::Zero();
|
||||
Nz::Matrix4f copy(zeroMatrix);
|
||||
REQUIRE(Serialize(context, zeroMatrix));
|
||||
zeroMatrix = Nz::Matrix4f::Identity(); // Random values
|
||||
REQUIRE(zeroMatrix != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &zeroMatrix));
|
||||
REQUIRE(zeroMatrix == copy);
|
||||
}
|
||||
|
||||
THEN("OrientedBox")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::OrientedBoxf zeroOBB = Nz::OrientedBoxf::Zero();
|
||||
Nz::OrientedBoxf copy(zeroOBB);
|
||||
REQUIRE(Serialize(context, zeroOBB));
|
||||
zeroOBB = Nz::OrientedBoxf(1, 1, 1, 1, 1, 1); // Random values
|
||||
REQUIRE(zeroOBB != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &zeroOBB));
|
||||
REQUIRE(zeroOBB == copy);
|
||||
}
|
||||
|
||||
THEN("Plane")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::Planef planeXY = Nz::Planef::XY();
|
||||
Nz::Planef copy(planeXY);
|
||||
REQUIRE(Serialize(context, planeXY));
|
||||
planeXY = Nz::Planef::YZ();
|
||||
REQUIRE(planeXY != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &planeXY));
|
||||
REQUIRE(planeXY == copy);
|
||||
}
|
||||
|
||||
THEN("Quaternion")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::Quaternionf quaternionIdentity = Nz::Quaternionf::Identity();
|
||||
Nz::Quaternionf copy(quaternionIdentity);
|
||||
REQUIRE(Serialize(context, quaternionIdentity));
|
||||
quaternionIdentity = Nz::Quaternionf::Zero();
|
||||
REQUIRE(quaternionIdentity != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &quaternionIdentity));
|
||||
REQUIRE(quaternionIdentity == copy);
|
||||
}
|
||||
|
||||
THEN("Ray")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::Rayf axisX = Nz::Rayf::AxisX();
|
||||
Nz::Rayf copy(axisX);
|
||||
REQUIRE(Serialize(context, axisX));
|
||||
axisX = Nz::Rayf::AxisY();
|
||||
REQUIRE(axisX != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &axisX));
|
||||
REQUIRE(axisX == copy);
|
||||
}
|
||||
|
||||
THEN("Rect")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::Rectf zeroRect = Nz::Rectf::Zero();
|
||||
Nz::Rectf copy(zeroRect);
|
||||
REQUIRE(Serialize(context, zeroRect));
|
||||
zeroRect = Nz::Rectf(1, 1, 1, 1); // Random values
|
||||
REQUIRE(zeroRect != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &zeroRect));
|
||||
REQUIRE(zeroRect == copy);
|
||||
}
|
||||
|
||||
THEN("Sphere")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::Spheref zeroSphere = Nz::Spheref::Zero();
|
||||
Nz::Spheref copy(zeroSphere);
|
||||
REQUIRE(Serialize(context, zeroSphere));
|
||||
zeroSphere = Nz::Spheref::Unit();
|
||||
REQUIRE(zeroSphere != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &zeroSphere));
|
||||
REQUIRE(zeroSphere == copy);
|
||||
}
|
||||
|
||||
THEN("Vector2")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::Vector2f unitX = Nz::Vector2f::UnitX();
|
||||
Nz::Vector2f copy(unitX);
|
||||
REQUIRE(Serialize(context, unitX));
|
||||
unitX = Nz::Vector2f::UnitY();
|
||||
REQUIRE(unitX != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &unitX));
|
||||
REQUIRE(unitX == copy);
|
||||
}
|
||||
|
||||
THEN("Vector3")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::Vector3f unitX = Nz::Vector3f::UnitX();
|
||||
Nz::Vector3f copy(unitX);
|
||||
REQUIRE(Serialize(context, unitX));
|
||||
unitX = Nz::Vector3f::UnitY();
|
||||
REQUIRE(unitX != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &unitX));
|
||||
REQUIRE(unitX == copy);
|
||||
}
|
||||
|
||||
THEN("Vector4")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::Vector4f unitX = Nz::Vector4f::UnitX();
|
||||
Nz::Vector4f copy(unitX);
|
||||
REQUIRE(Serialize(context, unitX));
|
||||
unitX = Nz::Vector4f::UnitY();
|
||||
REQUIRE(unitX != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &unitX));
|
||||
REQUIRE(unitX == copy);
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("We serialize core classes")
|
||||
{
|
||||
THEN("Color")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::Color red = Nz::Color::Red;
|
||||
Nz::Color copy(red);
|
||||
REQUIRE(Serialize(context, red));
|
||||
red = Nz::Color::Black;
|
||||
REQUIRE(red != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &red));
|
||||
REQUIRE(red == copy);
|
||||
}
|
||||
|
||||
THEN("String")
|
||||
{
|
||||
context.stream->SetCursorPos(0);
|
||||
Nz::String string = "string";
|
||||
Nz::String copy(string);
|
||||
REQUIRE(Serialize(context, string));
|
||||
string = "another";
|
||||
REQUIRE(string != copy);
|
||||
context.stream->SetCursorPos(0);
|
||||
REQUIRE(Unserialize(context, &string));
|
||||
REQUIRE(string == copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -82,6 +82,21 @@ SCENARIO("String", "[CORE][STRING]")
|
|||
}
|
||||
}
|
||||
|
||||
GIVEN("One character string")
|
||||
{
|
||||
Nz::String characterString;
|
||||
|
||||
WHEN("We set the string to one character")
|
||||
{
|
||||
characterString.Set('/');
|
||||
|
||||
THEN("The string must contain it")
|
||||
{
|
||||
REQUIRE(characterString == '/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO
|
||||
GIVEN("One unicode string")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Test
|
||||
Loading…
Reference in New Issue