Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
60d110ff
Commit
60d110ff
authored
Jun 28, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved doctests from module docstring into test functions
parent
f0b93467
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
13 deletions
+21
-13
tests/run/cpp_classes.pyx
tests/run/cpp_classes.pyx
+21
-13
No files found.
tests/run/cpp_classes.pyx
View file @
60d110ff
# tag: cpp
# tag: cpp
__doc__
=
u"""
>>> test_new_del()
(2, 2)
>>> test_rect_area(3, 4)
12.0
>>> test_square_area(15)
(225.0, 225.0)
>>> test_overload_bint_int()
202
201
"""
cdef
extern
from
"shapes.h"
namespace
"shapes"
:
cdef
extern
from
"shapes.h"
namespace
"shapes"
:
cdef
cppclass
Shape
:
cdef
cppclass
Shape
:
...
@@ -39,12 +27,23 @@ cdef extern from "shapes.h" namespace "shapes":
...
@@ -39,12 +27,23 @@ cdef extern from "shapes.h" namespace "shapes":
int
constructor_count
,
destructor_count
int
constructor_count
,
destructor_count
def
test_new_del
():
def
test_new_del
():
"""
>>> test_new_del()
2 0
2 2
"""
c
,
d
=
constructor_count
,
destructor_count
cdef
Rectangle
*
rect
=
new
Rectangle
(
10
,
20
)
cdef
Rectangle
*
rect
=
new
Rectangle
(
10
,
20
)
cdef
Circle
*
circ
=
new
Circle
(
15
)
cdef
Circle
*
circ
=
new
Circle
(
15
)
print
constructor_count
-
c
,
destructor_count
-
d
del
rect
,
circ
del
rect
,
circ
return
constructor_count
,
destructor_count
print
constructor_count
-
c
,
destructor_count
-
d
def
test_rect_area
(
w
,
h
):
def
test_rect_area
(
w
,
h
):
"""
>>> test_rect_area(3, 4)
12.0
"""
cdef
Rectangle
*
rect
=
new
Rectangle
(
w
,
h
)
cdef
Rectangle
*
rect
=
new
Rectangle
(
w
,
h
)
try
:
try
:
return
rect
.
area
()
return
rect
.
area
()
...
@@ -52,6 +51,11 @@ def test_rect_area(w, h):
...
@@ -52,6 +51,11 @@ def test_rect_area(w, h):
del
rect
del
rect
def
test_overload_bint_int
():
def
test_overload_bint_int
():
"""
>>> test_overload_bint_int()
202
201
"""
cdef
Rectangle
*
rect1
=
new
Rectangle
(
10
,
20
)
cdef
Rectangle
*
rect1
=
new
Rectangle
(
10
,
20
)
cdef
Rectangle
*
rect2
=
new
Rectangle
(
10
,
20
)
cdef
Rectangle
*
rect2
=
new
Rectangle
(
10
,
20
)
...
@@ -63,6 +67,10 @@ def test_overload_bint_int():
...
@@ -63,6 +67,10 @@ def test_overload_bint_int():
del
rect2
del
rect2
def
test_square_area
(
w
):
def
test_square_area
(
w
):
"""
>>> test_square_area(15)
(225.0, 225.0)
"""
cdef
Square
*
sqr
=
new
Square
(
w
)
cdef
Square
*
sqr
=
new
Square
(
w
)
cdef
Rectangle
*
rect
=
sqr
cdef
Rectangle
*
rect
=
sqr
try
:
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment