core(test): update cv::Ptr tests

This commit is contained in:
Alexander Alekhin 2018-09-07 22:16:53 +00:00
parent 15aee09c7f
commit 64b3c1e691

View File

@ -98,22 +98,25 @@ TEST(Core_Ptr, owning_ctor)
Ptr<void> p(r);
EXPECT_EQ(r, p.get());
}
EXPECT_TRUE(deleted);
{
Ptr<int> p(&dummyObject, ReportingDeleter(&deleted));
EXPECT_EQ(&dummyObject, p.get());
}
EXPECT_TRUE(deleted);
{
Ptr<void> p((void*)0, ReportingDeleter(&deleted));
EXPECT_NULL(p.get());
}
EXPECT_TRUE(deleted); // Differ from OpenCV 3.4 (but conformant to std::shared_ptr, see below)
EXPECT_FALSE(deleted);
{
std::shared_ptr<void> p((void*)0, ReportingDeleter(&deleted));
EXPECT_NULL(p.get());
}
EXPECT_TRUE(deleted);
}
TEST(Core_Ptr, sharing_ctor)
@ -337,7 +340,7 @@ TEST(Core_Ptr, casts)
Ptr<SubReporter> p2 = p1.dynamicCast<SubReporter>();
EXPECT_NULL(p2.get());
p1.release();
EXPECT_FALSE(deleted);
EXPECT_TRUE(deleted);
}
EXPECT_TRUE(deleted);
@ -400,4 +403,16 @@ TEST(Core_Ptr, specialized_deleter)
ASSERT_TRUE(sd.deleted);
}
TEST(Core_Ptr, specialized_deleter_via_reset)
{
SpeciallyDeletable sd;
{
Ptr<SpeciallyDeletable> p;
p.reset(&sd);
}
ASSERT_TRUE(sd.deleted);
}
}} // namespace