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
c71cde5f
Commit
c71cde5f
authored
May 12, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix doctest in Py3
parent
2bc8e238
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
40 deletions
+40
-40
tests/run/unicode_indexing.pyx
tests/run/unicode_indexing.pyx
+40
-40
No files found.
tests/run/unicode_indexing.pyx
View file @
c71cde5f
...
@@ -10,14 +10,14 @@ ustring = _ustring
...
@@ -10,14 +10,14 @@ ustring = _ustring
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
def
index
(
unicode
ustring
,
Py_ssize_t
i
):
def
index
(
unicode
ustring
,
Py_ssize_t
i
):
"""
"""
>>> index(ustring, 0)
>>> index(ustring, 0)
== 'a'
u'a'
True
>>> index(ustring, 2)
>>> index(ustring, 2)
== 'e'
u'e'
True
>>> index(ustring, -1)
>>> index(ustring, -1)
== '6'
u'6'
True
>>> index(ustring, -len(ustring))
>>> index(ustring, -len(ustring))
== 'a'
u'a'
True
>>> index(ustring, len(ustring))
>>> index(ustring, len(ustring))
Traceback (most recent call last):
Traceback (most recent call last):
...
@@ -32,14 +32,14 @@ def index(unicode ustring, Py_ssize_t i):
...
@@ -32,14 +32,14 @@ def index(unicode ustring, Py_ssize_t i):
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
def
index_literal
(
Py_ssize_t
i
):
def
index_literal
(
Py_ssize_t
i
):
"""
"""
>>> index_literal(0)
>>> index_literal(0)
== 'a'
u'a'
True
>>> index_literal(2)
>>> index_literal(2)
== 'e'
u'e'
True
>>> index_literal(-1)
>>> index_literal(-1)
== '6'
u'6'
True
>>> index_literal(-len('azerty123456'))
>>> index_literal(-len('azerty123456'))
== 'a'
u'a'
True
>>> index_literal(len(ustring))
>>> index_literal(len(ustring))
Traceback (most recent call last):
Traceback (most recent call last):
...
@@ -112,16 +112,16 @@ def index_literal_pyunicode_coerce_no_check(int i):
...
@@ -112,16 +112,16 @@ def index_literal_pyunicode_coerce_no_check(int i):
@
cython
.
boundscheck
(
False
)
@
cython
.
boundscheck
(
False
)
def
index_no_boundscheck
(
unicode
ustring
,
Py_ssize_t
i
):
def
index_no_boundscheck
(
unicode
ustring
,
Py_ssize_t
i
):
"""
"""
>>> index_no_boundscheck(ustring, 0)
>>> index_no_boundscheck(ustring, 0)
== 'a'
u'a'
True
>>> index_no_boundscheck(ustring, 2)
>>> index_no_boundscheck(ustring, 2)
== 'e'
u'e'
True
>>> index_no_boundscheck(ustring, -1)
>>> index_no_boundscheck(ustring, -1)
== '6'
u'6'
True
>>> index_no_boundscheck(ustring, len(ustring)-1)
>>> index_no_boundscheck(ustring, len(ustring)-1)
== '6'
u'6'
True
>>> index_no_boundscheck(ustring, -len(ustring))
>>> index_no_boundscheck(ustring, -len(ustring))
== 'a'
u'a'
True
"""
"""
return
ustring
[
i
]
return
ustring
[
i
]
...
@@ -132,12 +132,12 @@ def index_no_boundscheck(unicode ustring, Py_ssize_t i):
...
@@ -132,12 +132,12 @@ def index_no_boundscheck(unicode ustring, Py_ssize_t i):
@
cython
.
boundscheck
(
False
)
@
cython
.
boundscheck
(
False
)
def
unsigned_index_no_boundscheck
(
unicode
ustring
,
unsigned
int
i
):
def
unsigned_index_no_boundscheck
(
unicode
ustring
,
unsigned
int
i
):
"""
"""
>>> unsigned_index_no_boundscheck(ustring, 0)
>>> unsigned_index_no_boundscheck(ustring, 0)
== 'a'
u'a'
True
>>> unsigned_index_no_boundscheck(ustring, 2)
>>> unsigned_index_no_boundscheck(ustring, 2)
== 'e'
u'e'
True
>>> unsigned_index_no_boundscheck(ustring, len(ustring)-1)
>>> unsigned_index_no_boundscheck(ustring, len(ustring)-1)
== '6'
u'6'
True
"""
"""
return
ustring
[
i
]
return
ustring
[
i
]
...
@@ -198,10 +198,10 @@ def index_compare_string(unicode ustring, Py_ssize_t i, unicode other):
...
@@ -198,10 +198,10 @@ def index_compare_string(unicode ustring, Py_ssize_t i, unicode other):
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
def
index_multiply
(
unicode
ustring
,
Py_ssize_t
i
,
int
mul
):
def
index_multiply
(
unicode
ustring
,
Py_ssize_t
i
,
int
mul
):
"""
"""
>>> ustring[0] * 5
>>> ustring[0] * 5
== 'aaaaa'
u'aaaaa'
True
>>> index_multiply(ustring, 0, 5)
>>> index_multiply(ustring, 0, 5)
== 'aaaaa'
u'aaaaa'
True
"""
"""
return
ustring
[
i
]
*
mul
return
ustring
[
i
]
*
mul
...
@@ -213,9 +213,9 @@ def index_multiply(unicode ustring, Py_ssize_t i, int mul):
...
@@ -213,9 +213,9 @@ def index_multiply(unicode ustring, Py_ssize_t i, int mul):
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
@
cython
.
test_fail_if_path_exists
(
"//IndexNode//CoerceToPyTypeNode"
)
def
index_add
(
unicode
ustring
,
Py_ssize_t
i
,
Py_ssize_t
j
):
def
index_add
(
unicode
ustring
,
Py_ssize_t
i
,
Py_ssize_t
j
):
"""
"""
>>> ustring[0] + ustring[-1]
>>> ustring[0] + ustring[-1]
== 'a6'
u'a6'
True
>>> index_add(ustring, 0, -1)
>>> index_add(ustring, 0, -1)
== 'a6'
u'a6'
True
"""
"""
return
ustring
[
i
]
+
ustring
[
j
]
return
ustring
[
i
]
+
ustring
[
j
]
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