Files
NazaraEngine/tests/Engine/Core/RefCounted.cpp
Gawaboumga 1d5518b0d3 Documentation for RefCounted
Former-commit-id: 45bd646d027ba91fc3d399631fc0518ba172385d
2016-02-21 14:25:26 +01:00

30 lines
731 B
C++

#include <Nazara/Core/RefCounted.hpp>
#include <Catch/catch.hpp>
SCENARIO("RefCounted", "[CORE][REFCOUNTED]")
{
GIVEN("A refcounted persistent")
{
Nz::RefCounted refCounted;
REQUIRE(refCounted.IsPersistent() == true);
WHEN("We add a reference to this persistent object")
{
THEN("Number of references should be one")
{
refCounted.AddReference();
REQUIRE(refCounted.GetReferenceCount() == 1);
REQUIRE(refCounted.RemoveReference() == false);
}
AND_THEN("We suppress the reference, object is still alive")
{
refCounted.AddReference();
REQUIRE(refCounted.IsPersistent());
REQUIRE(refCounted.RemoveReference() == false);
REQUIRE(refCounted.GetReferenceCount() == 0);
}
}
}
}