mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 19:51:58 +01:00
merge some changes from develop branch; modernize and clean-up code; remove support for compiling without POCO_WIN32_UTF8
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
|
||||
using Poco::AutoPtr;
|
||||
using Poco::makeAuto;
|
||||
using Poco::NullPointerException;
|
||||
|
||||
|
||||
@@ -28,6 +29,14 @@ namespace
|
||||
{
|
||||
++_count;
|
||||
}
|
||||
|
||||
explicit TestObj(int value): _rc(1)
|
||||
{
|
||||
}
|
||||
|
||||
TestObj(int value1, const std::string& value2): _rc(1)
|
||||
{
|
||||
}
|
||||
|
||||
void duplicate()
|
||||
{
|
||||
@@ -92,6 +101,14 @@ void AutoPtrTest::testAutoPtr()
|
||||
ptr3 = ptr2;
|
||||
assertTrue (ptr2->rc() == 2);
|
||||
assertTrue (TestObj::count() > 0);
|
||||
|
||||
AutoPtr<TestObj> ptr4 = std::move(ptr);
|
||||
assertTrue (ptr4->rc() == 1);
|
||||
assertTrue (ptr.isNull());
|
||||
|
||||
ptr3 = std::move(ptr4);
|
||||
assertTrue (ptr4.isNull());
|
||||
assertTrue (ptr3->rc() == 1);
|
||||
}
|
||||
assertTrue (TestObj::count() == 0);
|
||||
}
|
||||
@@ -165,6 +182,19 @@ void AutoPtrTest::testOps()
|
||||
}
|
||||
|
||||
|
||||
void AutoPtrTest::testMakeAuto()
|
||||
{
|
||||
AutoPtr<TestObj> ptr = makeAuto<TestObj>();
|
||||
assertTrue (ptr->rc() == 1);
|
||||
|
||||
ptr = makeAuto<TestObj>(42);
|
||||
assertTrue (ptr->rc() == 1);
|
||||
|
||||
ptr = makeAuto<TestObj>(42, "fortytwo");
|
||||
assertTrue (ptr->rc() == 1);
|
||||
}
|
||||
|
||||
|
||||
void AutoPtrTest::setUp()
|
||||
{
|
||||
}
|
||||
@@ -181,6 +211,7 @@ CppUnit::Test* AutoPtrTest::suite()
|
||||
|
||||
CppUnit_addTest(pSuite, AutoPtrTest, testAutoPtr);
|
||||
CppUnit_addTest(pSuite, AutoPtrTest, testOps);
|
||||
CppUnit_addTest(pSuite, AutoPtrTest, testMakeAuto);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user