|
|
@@ -42,6 +42,15 @@ public:
|
|
|
TS_ASSERT_DIFFERS( c1.get(), c2.get() );
|
|
|
}
|
|
|
|
|
|
+ void test_copy_object_is_deep_equals() {
|
|
|
+ using vec_t = std::vector<int>;
|
|
|
+ vec_t my_vec = { 1, 3, 5, 3, 6, 1, 2, -1, 0 };
|
|
|
+ copy_ptr<vec_t> c1{ new vec_t{ my_vec } };
|
|
|
+ TS_ASSERT_EQUALS( *c1, my_vec );
|
|
|
+ copy_ptr<vec_t> c2{ c1 };
|
|
|
+ TS_ASSERT_EQUALS( *c2, *c1 );
|
|
|
+ }
|
|
|
+
|
|
|
void test_clone_polymorpic_object() {
|
|
|
using ptr_t = clone_ptr<base, &base::clone>;
|
|
|
ptr_t c0 { new derived_0 };
|
|
|
@@ -49,4 +58,15 @@ public:
|
|
|
ptr_t c1 { new derived_1 };
|
|
|
TS_ASSERT_EQUALS( ptr_t( c1 )->id(), derived_1::ID);
|
|
|
}
|
|
|
+
|
|
|
+ void test_does_own() const {
|
|
|
+ bool has_delete{false};
|
|
|
+ struct test_t {
|
|
|
+ ~test_t() { _r = true; }
|
|
|
+ bool & _r;
|
|
|
+ };
|
|
|
+ test_t * test_struct = new test_t{has_delete};
|
|
|
+ copy_ptr<test_t, nullptr>{ std::move(test_struct) };
|
|
|
+ TS_ASSERT_EQUALS(has_delete, true);
|
|
|
+ }
|
|
|
};
|