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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
f76f35ba
Commit
f76f35ba
authored
Mar 23, 2018
by
Callie LeFave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test `test_fused_pointer_except_null`
parent
6e6306cf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
tests/run/fused_types.pyx
tests/run/fused_types.pyx
+32
-0
No files found.
tests/run/fused_types.pyx
View file @
f76f35ba
...
...
@@ -119,6 +119,38 @@ def test_fused_with_pointer():
print
print
fused_with_pointer
(
string_array
).
decode
(
'ascii'
)
cdef
fused_type1
*
fused_pointer_except_null
(
fused_type1
x
)
except
NULL
:
if
fused_type1
is
string_t
:
assert
(
bool
(
x
))
else
:
assert
(
x
<
10
)
return
&
x
def
test_fused_pointer_except_null
(
value
):
"""
>>> test_fused_pointer_except_null(1)
1
>>> test_fused_pointer_except_null(2.0)
2.0
>>> test_fused_pointer_except_null(b'foo')
foo
>>> test_fused_pointer_except_null(16)
Traceback (most recent call last):
AssertionError
>>> test_fused_pointer_except_null(15.1)
Traceback (most recent call last):
AssertionError
>>> test_fused_pointer_except_null(b'')
Traceback (most recent call last):
AssertionError
"""
if
isinstance
(
value
,
int
):
print
fused_pointer_except_null
(
<
cython
.
int
>
value
)[
0
]
elif
isinstance
(
value
,
float
):
print
fused_pointer_except_null
(
<
cython
.
float
>
value
)[
0
]
elif
isinstance
(
value
,
bytes
):
print
fused_pointer_except_null
(
<
string_t
>
value
)[
0
].
decode
(
'ascii'
)
include
"cythonarrayutil.pxi"
cpdef
cython
.
integral
test_fused_memoryviews
(
cython
.
integral
[:,
::
1
]
a
):
...
...
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