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
53e50941
Commit
53e50941
authored
Jul 17, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #502, handle implicitly unsigned chars.
parent
8f8ef5cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
49 deletions
+53
-49
tests/run/c_int_types_T255.pyx
tests/run/c_int_types_T255.pyx
+53
-49
No files found.
tests/run/c_int_types_T255.pyx
View file @
53e50941
...
...
@@ -2,55 +2,6 @@ __doc__ = u""
# -------------------------------------------------------------------
CHAR_MAX
=
<
char
>
((
<
unsigned
char
>-
1
)
>>
1
)
CHAR_MIN
=
(
-
CHAR_MAX
-
1
)
def
test_char
(
char
x
):
u"""
>>> test_char(CHAR_MIN-1) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
OverflowError: ...
>>> test_char(CHAR_MIN) == CHAR_MIN
True
>>> test_char(-1)
-1
>>> test_char(0)
0
>>> test_char(1)
1
>>> test_char(CHAR_MAX) == CHAR_MAX
True
>>> test_char(CHAR_MAX+1) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
OverflowError: ...
"""
return
x
def
test_add_char
(
x
,
y
):
u"""
>>> test_add_char(CHAR_MIN, -1) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
OverflowError: ...
>>> test_add_char(CHAR_MIN, 0) == CHAR_MIN
True
>>> test_add_char(CHAR_MIN, 1) == CHAR_MIN+1
True
>>> test_add_char(CHAR_MAX, -1) == CHAR_MAX-1
True
>>> test_add_char(CHAR_MAX, 0) == CHAR_MAX
True
>>> test_add_char(CHAR_MAX, 1) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
OverflowError: ...
"""
cdef
char
r
=
x
+
y
return
r
SCHAR_MAX
=
<
signed
char
>
((
<
unsigned
char
>-
1
)
>>
1
)
SCHAR_MIN
=
(
-
SCHAR_MAX
-
1
)
...
...
@@ -128,6 +79,59 @@ def test_add_uchar(x, y):
cdef
unsigned
char
r
=
x
+
y
return
r
# chars may be signed or unsigned
if
(
<
char
>-
1
)
<
0
:
CHAR_MAX
=
SCHAR_MAX
CHAR_MIN
=
SCHAR_MIN
else
:
CHAR_MAX
=
UCHAR_MAX
CHAR_MIN
=
0
def
test_char
(
char
x
):
u"""
>>> test_char(CHAR_MIN-1) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
OverflowError: ...
>>> test_char(CHAR_MIN) == CHAR_MIN
True
>>> test_char(-1)
-1
>>> test_char(0)
0
>>> test_char(1)
1
>>> test_char(CHAR_MAX) == CHAR_MAX
True
>>> test_char(CHAR_MAX+1) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
OverflowError: ...
"""
return
x
def
test_add_char
(
x
,
y
):
u"""
>>> test_add_char(CHAR_MIN, -1) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
OverflowError: ...
>>> test_add_char(CHAR_MIN, 0) == CHAR_MIN
True
>>> test_add_char(CHAR_MIN, 1) == CHAR_MIN+1
True
>>> test_add_char(CHAR_MAX, -1) == CHAR_MAX-1
True
>>> test_add_char(CHAR_MAX, 0) == CHAR_MAX
True
>>> test_add_char(CHAR_MAX, 1) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
OverflowError: ...
"""
cdef
char
r
=
x
+
y
return
r
# -------------------------------------------------------------------
SHORT_MAX
=
<
short
>
((
<
unsigned
short
>-
1
)
>>
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