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
Gwenaël Samain
cython
Commits
d22ebc4b
Commit
d22ebc4b
authored
Apr 20, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended test case
parent
b629c04e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
tests/run/for_in_string.pyx
tests/run/for_in_string.pyx
+39
-0
No files found.
tests/run/for_in_string.pyx
View file @
d22ebc4b
cimport
cython
bytes_abc
=
b'abc'
bytes_ABC
=
b'ABC'
...
...
@@ -20,6 +21,8 @@ def for_in_bytes(bytes s):
else
:
return
'X'
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
for_char_in_bytes
(
bytes
s
):
"""
>>> for_char_in_bytes(bytes_abc)
...
...
@@ -34,6 +37,25 @@ def for_char_in_bytes(bytes s):
else
:
return
'X'
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
for_char_in_enumerate_bytes
(
bytes
s
):
"""
>>> for_char_in_enumerate_bytes(bytes_abc)
'X'
>>> for_char_in_enumerate_bytes(bytes_ABC)
2
"""
cdef
char
c
cdef
Py_ssize_t
i
for
i
,
c
in
enumerate
(
s
):
if
c
==
b'C'
:
return
i
else
:
return
'X'
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
for_pyunicode_in_unicode
(
unicode
s
):
"""
>>> for_pyunicode_in_unicode(unicode_abc)
...
...
@@ -47,3 +69,20 @@ def for_pyunicode_in_unicode(unicode s):
return
'C'
else
:
return
'X'
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
for_pyunicode_in_enumerate_unicode
(
unicode
s
):
"""
>>> for_pyunicode_in_enumerate_unicode(unicode_abc)
'X'
>>> for_pyunicode_in_enumerate_unicode(unicode_ABC)
2
"""
cdef
Py_UNICODE
c
cdef
Py_ssize_t
i
for
i
,
c
in
enumerate
(
s
):
if
c
==
u'C'
:
return
i
else
:
return
'X'
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