Documentation for ObjectRef

Former-commit-id: 3c704ed4e8999b0cdc66f6fe29ca0f170cc6619c
This commit is contained in:
Gawaboumga
2016-02-21 14:22:57 +01:00
parent de5a994a5c
commit 040c8b099f
2 changed files with 161 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
#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());
}
}
}
}