Move world on unordered_map and object_ptr

This commit is contained in:
Jiga228
2025-10-18 14:26:22 +07:00
parent bed233e56c
commit 0ec86e3de8
8 changed files with 99 additions and 39 deletions
+33
View File
@@ -1,6 +1,21 @@
#include <gtest/gtest.h>
#include "Types/object_ptr.hpp"
class TestClass
{
int* test_ptr_;
public:
TestClass(int* test_ptr) : test_ptr_(test_ptr)
{
*test_ptr_ = 1;
}
~TestClass()
{
*test_ptr_ = 2;
}
};
TEST(object_ptr_test, base_test)
{
int* test = new int(123);
@@ -23,4 +38,22 @@ TEST(object_ptr_test, check_destry)
ptr.destroy();
EXPECT_EQ(ptr.get(), nullptr);
EXPECT_EQ(ptr2.get(), nullptr);
}
TEST(object_ptr_test, check_destroy)
{
int* test = new int(0);
{
UType::object_ptr<TestClass> ptr(new TestClass(test));
EXPECT_EQ(*test, 1);
}
EXPECT_EQ(*test, 2);
*test = 0;
{
UType::object_ptr<TestClass> ptr(new TestClass(test));
UType::object_ptr<TestClass> ptr2(ptr);
EXPECT_EQ(*test, 1);
}
EXPECT_EQ(*test, 2);
}