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
Boxiang Sun
cython
Commits
04ff4ecc
Commit
04ff4ecc
authored
Apr 15, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended unicode iteration tests
parent
923aaab7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
7 deletions
+138
-7
tests/run/py_ucs4_type.pyx
tests/run/py_ucs4_type.pyx
+38
-1
tests/run/py_unicode_type.pyx
tests/run/py_unicode_type.pyx
+18
-2
tests/run/reversed_iteration.pyx
tests/run/reversed_iteration.pyx
+82
-4
No files found.
tests/run/py_ucs4_type.pyx
View file @
04ff4ecc
...
...
@@ -163,8 +163,45 @@ def count_lower_case_characters(unicode ustring):
count
+=
1
return
count
@
cython
.
test_assert_path_exists
(
'//SwitchStatNode'
,
@
cython
.
test_assert_path_exists
(
'//PythonCapiCallNode'
,
'//ForFromStatNode'
)
@
cython
.
test_fail_if_path_exists
(
'//SimpleCallNode'
,
'//ForInStatNode'
)
def
count_lower_case_characters_slice
(
unicode
ustring
):
"""
>>> count_lower_case_characters_slice(mixed_ustring)
10
>>> count_lower_case_characters_slice(lower_ustring)
14
>>> sum([ 1 for uchar in lower_ustring[1:-1] if uchar.islower() ])
14
"""
cdef
Py_ssize_t
count
=
0
for
uchar
in
ustring
[
1
:
-
1
]:
if
uchar
.
islower
():
count
+=
1
return
count
@
cython
.
test_assert_path_exists
(
'//PythonCapiCallNode'
,
'//ForFromStatNode'
)
@
cython
.
test_fail_if_path_exists
(
'//SimpleCallNode'
,
'//ForInStatNode'
)
def
count_lower_case_characters_slice_reversed
(
unicode
ustring
):
"""
>>> count_lower_case_characters_slice_reversed(mixed_ustring)
10
>>> count_lower_case_characters_slice_reversed(lower_ustring)
14
>>> sum([ 1 for uchar in lower_ustring[-2:0:-1] if uchar.islower() ])
14
"""
cdef
Py_ssize_t
count
=
0
for
uchar
in
ustring
[
-
2
:
0
:
-
1
]:
if
uchar
.
islower
():
count
+=
1
return
count
@
cython
.
test_assert_path_exists
(
'//SwitchStatNode'
)
@
cython
.
test_fail_if_path_exists
(
'//ForInStatNode'
)
def
iter_and_in
():
"""
...
...
tests/run/py_unicode_type.pyx
View file @
04ff4ecc
...
...
@@ -163,6 +163,23 @@ def count_lower_case_characters(unicode ustring):
count
+=
1
return
count
@
cython
.
test_assert_path_exists
(
'//PythonCapiCallNode'
,
'//ForFromStatNode'
)
@
cython
.
test_fail_if_path_exists
(
'//SimpleCallNode'
,
'//ForInStatNode'
)
def
count_lower_case_characters_slice
(
unicode
ustring
):
"""
>>> count_lower_case_characters_slice(mixed_ustring)
10
>>> count_lower_case_characters_slice(lower_ustring)
14
"""
cdef
Py_ssize_t
count
=
0
for
uchar
in
ustring
[
1
:
-
1
]:
if
uchar
.
islower
():
count
+=
1
return
count
@
cython
.
test_assert_path_exists
(
'//SwitchStatNode'
,
'//ForFromStatNode'
)
@
cython
.
test_fail_if_path_exists
(
'//ForInStatNode'
)
...
...
@@ -179,8 +196,7 @@ def iter_and_in():
if
c
in
u'abCDefGh'
:
print
c
@
cython
.
test_assert_path_exists
(
'//SwitchStatNode'
,
'//ForFromStatNode'
)
@
cython
.
test_assert_path_exists
(
'//SwitchStatNode'
)
@
cython
.
test_fail_if_path_exists
(
'//ForInStatNode'
)
def
index_and_in
():
"""
...
...
tests/run/reversed_iteration.pyx
View file @
04ff4ecc
...
...
@@ -181,11 +181,11 @@ def reversed_unicode_slice(unicode u):
return
result
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
def
reversed_unicode_slice_step
(
unicode
u
):
def
reversed_unicode_slice_
neg_
step
(
unicode
u
):
"""
>>> print(''.join(_reversed(unicode_string[-2:1:-1])))
cDE
>>> print(''.join(reversed_unicode_slice_step(unicode_string)))
>>> print(''.join(reversed_unicode_slice_
neg_
step(unicode_string)))
cDE
"""
result
=
[]
...
...
@@ -194,11 +194,76 @@ def reversed_unicode_slice_step(unicode u):
return
result
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
def
reversed_unicode_slice_step_only
(
unicode
u
):
def
reversed_unicode_slice_pos_step
(
unicode
u
):
"""
>>> print(''.join(_reversed(unicode_string[1:-2:1])))
Dcb
>>> print(''.join(reversed_unicode_slice_pos_step(unicode_string)))
Dcb
"""
result
=
[]
for
c
in
reversed
(
u
[
1
:
-
2
:
1
]):
result
.
append
(
c
)
return
result
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
def
reversed_unicode_slice_start_pos_step
(
unicode
u
):
"""
>>> print(''.join(_reversed(unicode_string[2::1])))
FEDc
>>> print(''.join(reversed_unicode_slice_start_pos_step(unicode_string)))
FEDc
"""
result
=
[]
for
c
in
reversed
(
u
[
2
::
1
]):
result
.
append
(
c
)
return
result
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
def
reversed_unicode_slice_start_neg_step
(
unicode
u
):
"""
>>> print(''.join(_reversed(unicode_string[3::-1])))
abcD
>>> print(''.join(reversed_unicode_slice_start_neg_step(unicode_string)))
abcD
"""
result
=
[]
for
c
in
reversed
(
u
[
3
::
-
1
]):
result
.
append
(
c
)
return
result
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
def
reversed_unicode_slice_end_pos_step
(
unicode
u
):
"""
>>> print(''.join(_reversed(unicode_string[:-2:1])))
Dcba
>>> print(''.join(reversed_unicode_slice_end_pos_step(unicode_string)))
Dcba
"""
result
=
[]
for
c
in
reversed
(
u
[:
-
2
:
1
]):
result
.
append
(
c
)
return
result
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
def
reversed_unicode_slice_end_neg_step
(
unicode
u
):
"""
>>> print(''.join(_reversed(unicode_string[:-3:-1])))
EF
>>> print(''.join(reversed_unicode_slice_end_neg_step(unicode_string)))
EF
"""
result
=
[]
for
c
in
reversed
(
u
[:
-
3
:
-
1
]):
result
.
append
(
c
)
return
result
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
def
reversed_unicode_slice_neg_step_only
(
unicode
u
):
"""
>>> print(''.join(_reversed(unicode_string[::-1])))
abcDEF
>>> print(''.join(reversed_unicode_slice_step_only(unicode_string)))
>>> print(''.join(reversed_unicode_slice_
neg_
step_only(unicode_string)))
abcDEF
"""
result
=
[]
...
...
@@ -206,6 +271,19 @@ def reversed_unicode_slice_step_only(unicode u):
result
.
append
(
c
)
return
result
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
def
reversed_unicode_slice_pos_step_only
(
unicode
u
):
"""
>>> print(''.join(_reversed(unicode_string[::1])))
FEDcba
>>> print(''.join(reversed_unicode_slice_pos_step_only(unicode_string)))
FEDcba
"""
result
=
[]
for
c
in
reversed
(
u
[::
1
]):
result
.
append
(
c
)
return
result
bytes_string
=
b'abcDEF'
join_bytes
=
b''
.
join
...
...
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