1#include <Core/Utils/Singleton.hpp>
3#include <catch2/catch_test_macros.hpp>
7 RA_SINGLETON_INTERFACE( TestSingleton );
13 TestSingleton() { cpt++; }
16int TestSingleton::cpt = 0;
18RA_SINGLETON_IMPLEMENTATION( TestSingleton );
20TEST_CASE(
"Core/Utils/Singleton",
"[unittests][Core][Core/Utils][Singleton]" ) {
22 REQUIRE( TestSingleton::getInstance() ==
nullptr );
23 auto p1 = TestSingleton::createInstance();
24 REQUIRE( TestSingleton::getInstance() !=
nullptr );
25 REQUIRE( p1 == TestSingleton::getInstance() );
26 REQUIRE( TestSingleton::cpt == 1 );
28 TestSingleton::destroyInstance();
29 REQUIRE( TestSingleton::getInstance() ==
nullptr );
30 auto p2 = TestSingleton::createInstance();
31 REQUIRE( TestSingleton::getInstance() !=
nullptr );
32 REQUIRE( p2 == TestSingleton::getInstance() );
33 REQUIRE( TestSingleton::cpt == 2 );