12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #include "tests/UniquePointerTests.h"
- #include "test/Test.h"
- #include "utils/UniquePointer.h"
- #include "utils/Utility.h"
- struct B final {
- static int instances;
- B() {
- instances++;
- }
- ~B() {
- instances--;
- }
- };
- int B::instances = 0;
- static void testDestroy() {
- {
- Core::UniquePointer<B> p(new B());
- CORE_TEST_EQUAL(1, B::instances);
- }
- CORE_TEST_EQUAL(0, B::instances);
- }
- static void testMoveDestroys() {
- {
- Core::UniquePointer<B> p1(new B());
- Core::UniquePointer<B> p2(new B());
- CORE_TEST_EQUAL(2, B::instances);
- p1 = Core::move(p2);
- CORE_TEST_EQUAL(1, B::instances);
- }
- CORE_TEST_EQUAL(0, B::instances);
- }
- void Core::UniquePointerTests::test() {
- testDestroy();
- testMoveDestroys();
- }
|