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
d92efd63
Commit
d92efd63
authored
Feb 21, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make test functions a bit more readable and add some additional tests
parent
98772dcf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
60 deletions
+97
-60
tests/run/unicode_slicing.pyx
tests/run/unicode_slicing.pyx
+97
-60
No files found.
tests/run/unicode_slicing.pyx
View file @
d92efd63
# coding: utf-8
__doc__
=
u"""
>>>
do_slice1
(u'abcdef', 2, 3)
>>>
slice_start_end
(u'abcdef', 2, 3)
c
>>>
do_slice2
(u'abcdef', 2, 3)
>>>
slice_start
(u'abcdef', 2, 3)
cdef
>>>
do_slice3
(u'abcdef', 2, 3)
>>>
slice_end
(u'abcdef', 2, 3)
ab
>>>
do_slice4
(u'abcdef', 2, 3)
>>>
slice_all
(u'abcdef', 2, 3)
abcdef
>>>
do_slice5
(u'abcdef', 2, 3)
>>>
slice_start_none
(u'abcdef', 2, 3)
cdef
>>>
do_slice6
(u'abcdef', 2, 3)
>>>
slice_none_end
(u'abcdef', 2, 3)
ab
>>>
do_slice7
(u'abcdef', 2, 3)
>>>
slice_none_none
(u'abcdef', 2, 3)
abcdef
>>> do_slice1(u'abcdef', 2, 10)
>>> slice_start_end(u'abcdef', 2, 10)
cdef
>>>
do_slice2
(u'abcdef', 2, 10)
>>>
slice_start
(u'abcdef', 2, 10)
cdef
>>>
do_slice3
(u'abcdef', 2, 10)
>>>
slice_end
(u'abcdef', 2, 10)
ab
>>>
do_slice4
(u'abcdef', 2, 10)
>>>
slice_all
(u'abcdef', 2, 10)
abcdef
>>> do_slice1(u'abcdef', 0, 5)
>>> slice_start_end(u'abcdef', 0, 5)
abcde
>>>
do_slice2
(u'abcdef', 0, 5)
>>>
slice_start
(u'abcdef', 0, 5)
abcdef
>>>
do_slice3
(u'abcdef', 0, 5)
>>>
slice_end
(u'abcdef', 0, 5)
<BLANKLINE>
>>>
do_slice4
(u'abcdef', 0, 5)
>>>
slice_all
(u'abcdef', 0, 5)
abcdef
>>>
do_slice5
(u'abcdef', 0, 5)
>>>
slice_start_none
(u'abcdef', 0, 5)
abcdef
>>>
do_slice6
(u'abcdef', 0, 5)
>>>
slice_none_end
(u'abcdef', 0, 5)
<BLANKLINE>
>>>
do_slice7
(u'abcdef', 0, 5)
>>>
slice_none_none
(u'abcdef', 0, 5)
abcdef
>>> do_slice1(u'abcdef', -6, -1)
>>> slice_start_end(u'abcdef', -6, -1)
abcde
>>> do_slice2(u'abcdef', -6, -1)
>>> slice_start(u'abcdef', -6, -1)
abcdef
>>> slice_end(u'abcdef', -6, -1)
<BLANKLINE>
>>> slice_all(u'abcdef', -6, -1)
abcdef
>>> slice_start_none(u'abcdef', -6, -1)
abcdef
>>>
do_slice3
(u'abcdef', -6, -1)
>>>
slice_none_end
(u'abcdef', -6, -1)
<BLANKLINE>
>>>
do_slice4
(u'abcdef', -6, -1)
>>>
slice_none_none
(u'abcdef', -6, -1)
abcdef
>>> do_slice5(u'abcdef', -6, -1)
>>> slice_start_end(u'abcdef', -6, -7)
<BLANKLINE>
>>> slice_start(u'abcdef', -6, -7)
abcdef
>>> slice_end(u'abcdef', -6, -7)
<BLANKLINE>
>>> slice_all(u'abcdef', -6, -7)
abcdef
>>> slice_start_none(u'abcdef', -6, -7)
abcdef
>>>
do_slice6(u'abcdef', -6, -1
)
>>>
slice_none_end(u'abcdef', -6, -7
)
<BLANKLINE>
>>>
do_slice7(u'abcdef', -6, -1
)
>>>
slice_none_none(u'abcdef', -6, -7
)
abcdef
>>> do_slice1(u'aАbБcСdДeЕfФ', 2, 8)
>>> slice_start_end(u'abcdef', -7, -7)
<BLANKLINE>
>>> slice_start(u'abcdef', -7, -7)
abcdef
>>> slice_end(u'abcdef', -7, -7)
<BLANKLINE>
>>> slice_all(u'abcdef', -7, -7)
abcdef
>>> slice_start_none(u'abcdef', -7, -7)
abcdef
>>> slice_none_end(u'abcdef', -7, -7)
<BLANKLINE>
>>> slice_none_none(u'abcdef', -7, -7)
abcdef
>>> slice_start_end(u'aАbБcСdДeЕfФ', 2, 8)
bБcСdД
>>>
do_slice2
(u'aАbБcСdДeЕfФ', 2, 8)
>>>
slice_start
(u'aАbБcСdДeЕfФ', 2, 8)
bБcСdДeЕfФ
>>>
do_slice3
(u'aАbБcСdДeЕfФ', 2, 8)
>>>
slice_end
(u'aАbБcСdДeЕfФ', 2, 8)
aА
>>>
do_slice4
(u'aАbБcСdДeЕfФ', 2, 8)
>>>
slice_all
(u'aАbБcСdДeЕfФ', 2, 8)
aАbБcСdДeЕfФ
>>>
do_slice5
(u'aАbБcСdДeЕfФ', 2, 8)
>>>
slice_start_none
(u'aАbБcСdДeЕfФ', 2, 8)
bБcСdДeЕfФ
>>>
do_slice6
(u'aАbБcСdДeЕfФ', 2, 8)
>>>
slice_none_end
(u'aАbБcСdДeЕfФ', 2, 8)
aА
>>>
do_slice7
(u'aАbБcСdДeЕfФ', 2, 8)
>>>
slice_none_none
(u'aАbБcСdДeЕfФ', 2, 8)
aАbБcСdДeЕfФ
>>> do_slice1(u'АБСДЕФ', 2, 4)
>>> slice_start_end(u'АБСДЕФ', 2, 4)
СД
>>>
do_slice2
(u'АБСДЕФ', 2, 4)
>>>
slice_start
(u'АБСДЕФ', 2, 4)
СДЕФ
>>>
do_slice3
(u'АБСДЕФ', 2, 4)
>>>
slice_end
(u'АБСДЕФ', 2, 4)
АБ
>>>
do_slice4
(u'АБСДЕФ', 2, 4)
>>>
slice_all
(u'АБСДЕФ', 2, 4)
АБСДЕФ
>>>
do_slice5
(u'АБСДЕФ', 2, 4)
>>>
slice_start_none
(u'АБСДЕФ', 2, 4)
СДЕФ
>>>
do_slice6
(u'АБСДЕФ', 2, 4)
>>>
slice_none_end
(u'АБСДЕФ', 2, 4)
АБ
>>>
do_slice7
(u'АБСДЕФ', 2, 4)
>>>
slice_none_none
(u'АБСДЕФ', 2, 4)
АБСДЕФ
>>> do_slice1(u'АБСДЕФ', -4, -2)
>>> slice_start_end(u'АБСДЕФ', -4, -2)
СД
>>>
do_slice2
(u'АБСДЕФ', -4, -2)
>>>
slice_start
(u'АБСДЕФ', -4, -2)
СДЕФ
>>>
do_slice3
(u'АБСДЕФ', -4, -2)
>>>
slice_end
(u'АБСДЕФ', -4, -2)
АБ
>>>
do_slice4
(u'АБСДЕФ', -4, -2)
>>>
slice_all
(u'АБСДЕФ', -4, -2)
АБСДЕФ
>>>
do_slice5
(u'АБСДЕФ', -4, -2)
>>>
slice_start_none
(u'АБСДЕФ', -4, -2)
СДЕФ
>>>
do_slice6
(u'АБСДЕФ', -4, -2)
>>>
slice_none_end
(u'АБСДЕФ', -4, -2)
АБ
>>>
do_slice7
(u'АБСДЕФ', -4, -2)
>>>
slice_none_none
(u'АБСДЕФ', -4, -2)
АБСДЕФ
>>> do_slice1(None, 2, 4)
>>> slice_start_end(None, 2, 4)
Traceback (most recent call last):
TypeError: 'NoneType' object is not subscriptable
>>>
do_slice2
(None, 2, 4)
>>>
slice_start
(None, 2, 4)
Traceback (most recent call last):
TypeError: 'NoneType' object is not subscriptable
>>>
do_slice3
(None, 2, 4)
>>>
slice_end
(None, 2, 4)
Traceback (most recent call last):
TypeError: 'NoneType' object is not subscriptable
>>>
do_slice4
(None, 2, 4)
>>>
slice_all
(None, 2, 4)
Traceback (most recent call last):
TypeError: 'NoneType' object is not subscriptable
>>>
do_slice5
(None, 2, 4)
>>>
slice_start_none
(None, 2, 4)
Traceback (most recent call last):
TypeError: 'NoneType' object is not subscriptable
>>>
do_slice6
(None, 2, 4)
>>>
slice_none_end
(None, 2, 4)
Traceback (most recent call last):
TypeError: 'NoneType' object is not subscriptable
>>>
do_slice7
(None, 2, 4)
>>>
slice_none_none
(None, 2, 4)
Traceback (most recent call last):
TypeError: 'NoneType' object is not subscriptable
"""
...
...
@@ -121,23 +158,23 @@ import sys
if
sys
.
version_info
[
0
]
>=
3
:
__doc__
=
__doc__
.
replace
(
u"(u'"
,
u"('"
).
replace
(
u" u'"
,
u" '"
)
def
do_slice1
(
unicode
s
,
int
i
,
int
j
):
def
slice_start_end
(
unicode
s
,
int
i
,
int
j
):
print
(
s
[
i
:
j
])
def
do_slice2
(
unicode
s
,
int
i
,
int
j
):
def
slice_start
(
unicode
s
,
int
i
,
int
j
):
print
(
s
[
i
:])
def
do_slice3
(
unicode
s
,
int
i
,
int
j
):
def
slice_end
(
unicode
s
,
int
i
,
int
j
):
print
(
s
[:
i
])
def
do_slice4
(
unicode
s
,
int
i
,
int
j
):
def
slice_all
(
unicode
s
,
int
i
,
int
j
):
print
(
s
[:])
def
do_slice5
(
unicode
s
,
int
i
,
int
j
):
def
slice_start_none
(
unicode
s
,
int
i
,
int
j
):
print
(
s
[
i
:
None
])
def
do_slice6
(
unicode
s
,
int
i
,
int
j
):
def
slice_none_end
(
unicode
s
,
int
i
,
int
j
):
print
(
s
[
None
:
i
])
def
do_slice7
(
unicode
s
,
int
i
,
int
j
):
def
slice_none_none
(
unicode
s
,
int
i
,
int
j
):
print
(
s
[
None
:
None
])
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