40 lines
988 B
C++
40 lines
988 B
C++
|
#include "Singleton.h"
|
||
|
#include <boost/test/unit_test.hpp>
|
||
|
|
||
|
class Test {
|
||
|
public:
|
||
|
size_t index;
|
||
|
};
|
||
|
|
||
|
BOOST_AUTO_TEST_CASE(LocalInstance) {
|
||
|
auto test = Amass::Singleton<Test>::instance();
|
||
|
BOOST_TEST(!test);
|
||
|
|
||
|
{
|
||
|
auto local = Amass::Singleton<Test>::instance<Amass::Construct>();
|
||
|
BOOST_TEST(local);
|
||
|
|
||
|
auto refer = Amass::Singleton<Test>::instance();
|
||
|
BOOST_TEST(refer);
|
||
|
}
|
||
|
|
||
|
test = Amass::Singleton<Test>::instance();
|
||
|
BOOST_TEST(!test);
|
||
|
}
|
||
|
|
||
|
BOOST_AUTO_TEST_CASE(GlobalInstance) {
|
||
|
auto test = Amass::Singleton<Test, Amass::GlobalInstance>::instance();
|
||
|
BOOST_TEST(test);
|
||
|
|
||
|
{
|
||
|
auto local = Amass::Singleton<Test, Amass::GlobalInstance>::instance();
|
||
|
BOOST_TEST(local);
|
||
|
|
||
|
auto refer = Amass::Singleton<Test, Amass::GlobalInstance>::instance();
|
||
|
BOOST_TEST(refer);
|
||
|
}
|
||
|
|
||
|
test = Amass::Singleton<Test, Amass::GlobalInstance>::instance();
|
||
|
BOOST_TEST(test);
|
||
|
}
|