Move world on unordered_map and object_ptr
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user