Commit 164ae885 authored by Robert Bradshaw's avatar Robert Bradshaw

make sure constructor/destructors are being called

parent 67164f05
__doc__ = u"""
>>> test_new_del()
(2, 2)
>>> test_rect_area(3, 4)
12.0
>>> test_square_area(15)
......@@ -23,11 +24,14 @@ cdef extern from "shapes.h" namespace shapes:
cdef cppclass Square(Rectangle):
int side
# __init__(int) # need function overloading
int constructor_count, destructor_count
def test_new_del():
cdef Rectangle *rect = new Rectangle(10, 20)
cdef Circle *circ = new Circle(15)
del rect, circ
return constructor_count, destructor_count
def test_rect_area(w, h):
cdef Rectangle *rect = new Rectangle(w, h)
......
......@@ -3,11 +3,15 @@
namespace shapes {
int constructor_count = 0;
int destructor_count = 0;
class Shape
{
public:
virtual float area() = 0;
virtual ~Shape() { }
Shape() { constructor_count++; }
virtual ~Shape() { destructor_count++; }
};
class Rectangle : public Shape
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment