2015-01-12 21:43:26 +01:00
|
|
|
/**
|
|
|
|
* @author Edouard DUPIN
|
|
|
|
*
|
|
|
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
|
|
*
|
2017-01-05 21:28:23 +01:00
|
|
|
* @license MPL v2.0 (see license file)
|
2015-01-12 21:43:26 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
2016-10-02 15:58:09 +02:00
|
|
|
#include <ememory/memory.hpp>
|
2017-05-08 23:48:36 +00:00
|
|
|
#include <test-debug/debug.hpp>
|
2015-01-12 21:43:26 +01:00
|
|
|
#define NAME "Shared_ptr"
|
|
|
|
|
2016-07-15 21:22:11 +02:00
|
|
|
class Example : public ememory::EnableSharedFromThis<Example> {
|
2015-01-12 21:43:26 +01:00
|
|
|
protected:
|
|
|
|
int32_t m_id;
|
|
|
|
public:
|
|
|
|
Example() {
|
|
|
|
static int32_t mid = 0;
|
|
|
|
m_id = mid++;
|
|
|
|
std::cout << "create Example [" << m_id << "]" << std::endl;
|
|
|
|
}
|
|
|
|
~Example() {
|
|
|
|
std::cout << "Remove Example [" << m_id << "]" << std::endl;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST(TestSTDSharedPtr, testBaseLocal) {
|
|
|
|
Example();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TestSTDSharedPtr, testBaseShared) {
|
2016-07-15 21:22:11 +02:00
|
|
|
ememory::SharedPtr<Example> tmp = ememory::makeShared<Example>();
|
2015-01-12 21:43:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(TestSTDSharedPtr, testBaseSharedDouble) {
|
2016-07-15 21:22:11 +02:00
|
|
|
ememory::SharedPtr<Example> tmp = ememory::makeShared<Example>();
|
|
|
|
ememory::SharedPtr<Example> tmp2 = tmp;
|
2015-01-12 21:43:26 +01:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
TEST(TestSTDSharedPtr, testBaseSharedDirectAndShared) {
|
|
|
|
Example tmp;
|
2016-07-15 21:22:11 +02:00
|
|
|
ememory::SharedPtr<Example> tmp2 = ememory::makeShared<tmp>;
|
2015-01-12 21:43:26 +01:00
|
|
|
}
|
|
|
|
*/
|