Fix (and test) that copy constructor decrements previous object counter
This commit is contained in:
1 parent
4a1a0c8855
commit
2e30a9f407
2 files changed
+21
-4
No files matched your search
+10
-1
@@ -28,6 +28,7 @@ public:
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
typedef rcp<MyBase> MyB;
|
||||
|
||||
class MyDerived : public MyBase
|
||||
{
|
||||
@@ -85,7 +86,6 @@ void test_booleans()
|
||||
|
||||
void test_create()
|
||||
{
|
||||
typedef rcp<MyBase> MyB;
|
||||
MyB myb = MyB::create(8, 9);
|
||||
assert(myb->x == 8);
|
||||
}
|
||||
@@ -124,6 +124,14 @@ void test_multi_construct_from_raw_pointers()
|
||||
}
|
||||
}
|
||||
|
||||
void test_copy_assignment_decrements_previous_reference()
|
||||
{
|
||||
MyB myb = MyB::create(12, 13);
|
||||
MyB myb2 = MyB::create(14, 15);
|
||||
myb = myb2;
|
||||
assert(myb->x == 14);
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
test_class_hierarchy();
|
||||
@@ -131,5 +139,6 @@ int main(int argc, char * argv[])
|
||||
test_booleans();
|
||||
test_create();
|
||||
test_multi_construct_from_raw_pointers();
|
||||
test_copy_assignment_decrements_previous_reference();
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user