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
Xavier Thompson
cython
Commits
7df719ae
Commit
7df719ae
authored
Oct 08, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test for refcount of cypclass results of subscript operations
parent
b4224faf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
tests/run/cypclass_subscript_refcounting.pyx
tests/run/cypclass_subscript_refcounting.pyx
+60
-0
No files found.
tests/run/cypclass_subscript_refcounting.pyx
0 → 100644
View file @
7df719ae
# mode: run
# tag: cpp, cpp11, pthread
# cython: experimental_cpp_class_def=True, language_level=2
from
libcpp.vector
cimport
vector
cdef
cypclass
Value
:
__dealloc__
(
self
)
with
gil
:
print
(
"Value destroyed"
)
def
test_cpp_index_refcounting
():
"""
>>> test_cpp_index_refcounting()
Value destroyed
0
"""
cdef
vector
[
Value
]
vec
vec
.
push_back
(
Value
())
a
=
vec
[
0
]
if
Cy_GETREF
(
a
)
!=
3
:
return
-
1
return
0
cdef
cypclass
Vector
[
T
]:
vector
[
T
]
vec
T
__getitem__
(
self
,
int
index
):
return
vec
[
index
]
def
test_cyp_template_index_refcounting
():
"""
>>> test_cyp_template_index_refcounting()
Value destroyed
0
"""
v
=
Vector
[
Value
]()
v
.
vec
.
push_back
(
Value
())
a
=
v
[
0
]
if
Cy_GETREF
(
a
)
!=
3
:
return
-
1
return
0
cdef
cypclass
ValueVector
:
vector
[
Value
]
vec
Value
__getitem__
(
self
,
int
index
):
return
vec
[
index
]
def
test_cyp_index_refcounting
():
"""
>>> test_cyp_index_refcounting()
Value destroyed
0
"""
v
=
ValueVector
()
v
.
vec
.
push_back
(
Value
())
a
=
v
[
0
]
if
Cy_GETREF
(
a
)
!=
3
:
return
-
1
return
0
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