Files
NazaraEngine/tests/Engine/Core/ObjectRef.cpp
Gawaboumga 040c8b099f Documentation for ObjectRef
Former-commit-id: 3c704ed4e8999b0cdc66f6fe29ca0f170cc6619c
2016-02-21 14:22:57 +01:00

42 lines
724 B
C++

#include <Nazara/Core/ObjectRef.hpp>
#include <Catch/catch.hpp>
#include <Nazara/Utility/Font.hpp>
SCENARIO("ObjectRef", "[CORE][OBJECTREF]")
{
GIVEN("A ObjectRef")
{
Nz::ObjectRef<Nz::Font> objectRef;
WHEN("We have two objectRef handling the same object")
{
Nz::Font font;
objectRef = &font;
Nz::ObjectRef<Nz::Font> otherRef(&font);
THEN("Pointers the same")
{
REQUIRE(objectRef.IsValid());
REQUIRE(otherRef.IsValid());
}
objectRef.Reset(nullptr);
}
WHEN("We assign it to a simple font")
{
Nz::Font font;
THEN("Release suppress the reference to the object")
{
objectRef.Reset(&font);
objectRef.Release();
REQUIRE(!objectRef.IsValid());
}
}
}
}