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
4cf301a1
Commit
4cf301a1
authored
Aug 28, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests for cypclass dict keys and values reference count
parent
22a9d00b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
tests/run/cypclass_builtin_dict.pyx
tests/run/cypclass_builtin_dict.pyx
+80
-0
No files found.
tests/run/cypclass_builtin_dict.pyx
View file @
4cf301a1
...
@@ -358,3 +358,83 @@ def test_scalar_types_dict():
...
@@ -358,3 +358,83 @@ def test_scalar_types_dict():
d
[
index
]
=
i
d
[
index
]
=
i
return
[(
key
,
value
)
for
(
key
,
value
)
in
d
.
items
()]
return
[(
key
,
value
)
for
(
key
,
value
)
in
d
.
items
()]
cdef
cypclass
DestroyCheckIndex
(
Index
):
__dealloc__
(
self
)
with
gil
:
print
(
"destroyed index"
,
self
.
index
)
cdef
cypclass
DestroyCheckValue
(
Value
):
__dealloc__
(
self
)
with
gil
:
print
(
"destroyed value"
,
self
.
value
)
def
test_items_destroyed
():
"""
>>> test_items_destroyed()
('destroyed index', 0)
('destroyed value', 0)
('destroyed index', 1)
('destroyed value', 1)
('destroyed index', 2)
('destroyed value', 2)
('destroyed index', 3)
('destroyed value', 3)
('destroyed index', 4)
('destroyed value', 4)
('destroyed index', 5)
('destroyed value', 5)
('destroyed index', 6)
('destroyed value', 6)
('destroyed index', 7)
('destroyed value', 7)
('destroyed index', 8)
('destroyed value', 8)
('destroyed index', 9)
('destroyed value', 9)
"""
d
=
cypdict
[
DestroyCheckIndex
,
DestroyCheckValue
]()
for
i
in
range
(
10
):
d
[
DestroyCheckIndex
(
i
)]
=
DestroyCheckValue
(
i
)
def
test_items_refcount
():
"""
>>> test_items_refcount()
1
"""
d
=
cypdict
[
Index
,
Value
]()
index
=
Index
()
value
=
Value
()
if
Cy_GETREF
(
index
)
!=
2
:
return
0
if
Cy_GETREF
(
value
)
!=
2
:
return
0
d
[
index
]
=
value
if
Cy_GETREF
(
index
)
!=
3
:
return
0
if
Cy_GETREF
(
value
)
!=
3
:
return
0
del
d
[
index
]
if
Cy_GETREF
(
index
)
!=
2
:
return
0
if
Cy_GETREF
(
value
)
!=
2
:
return
0
d
[
index
]
=
value
if
Cy_GETREF
(
index
)
!=
3
:
return
0
if
Cy_GETREF
(
value
)
!=
3
:
return
0
d
.
clear
()
if
Cy_GETREF
(
index
)
!=
2
:
return
0
if
Cy_GETREF
(
value
)
!=
2
:
return
0
d
[
index
]
=
value
if
Cy_GETREF
(
index
)
!=
3
:
return
0
if
Cy_GETREF
(
value
)
!=
3
:
return
0
d
=
cypdict
[
Index
,
Value
]()
if
Cy_GETREF
(
index
)
!=
2
:
return
0
if
Cy_GETREF
(
value
)
!=
2
:
return
0
return
1
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