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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
89af179f
Commit
89af179f
authored
Aug 28, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests for cypclass dict len() and clear() methods
parent
e8999df8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
tests/run/cypclass_builtin_dict.pyx
tests/run/cypclass_builtin_dict.pyx
+49
-0
No files found.
tests/run/cypclass_builtin_dict.pyx
View file @
89af179f
...
...
@@ -297,3 +297,52 @@ def test_setitem_after_dict_items_iterator():
except
RuntimeError
as
e
:
print
(
e
)
return
0
def
test_len
():
"""
>>> test_len()
1
"""
d
=
cypdict
[
Index
,
Value
]()
cdef
int
nb_elements
=
0
for
i
in
range
(
10
):
d
[
Index
(
i
)]
=
Value
(
i
)
for
k
in
d
:
nb_elements
+=
1
if
d
.
__len__
()
!=
nb_elements
:
return
0
if
nb_elements
!=
10
:
return
0
return
1
def
test_clear
():
"""
>>> test_clear()
1
"""
d
=
cypdict
[
Index
,
Value
]()
for
i
in
range
(
10
):
d
[
Index
(
i
)]
=
Value
(
i
)
if
d
.
__len__
()
!=
10
:
return
-
1
d
.
clear
()
if
d
.
__len__
()
!=
0
:
return
0
return
1
def
test_clear_exception_dict_iterator
():
"""
>>> test_clear_exception_dict_iterator()
Modifying a dictionary with active iterators
1
"""
d
=
cypdict
[
Index
,
Value
]()
iterator
=
d
.
begin
()
try
:
with
nogil
:
d
.
clear
()
with
gil
:
return
0
except
RuntimeError
as
e
:
print
(
e
)
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