Commit 77fe9327 authored by Callie LeFave's avatar Callie LeFave Committed by Stefan Behnel

Fix `fused_pointer_except_null` test undefined behavior

Signed-off-by: default avatarStefan Behnel <stefan_ml@behnel.de>
parent 798f08ed
...@@ -119,12 +119,12 @@ def test_fused_with_pointer(): ...@@ -119,12 +119,12 @@ def test_fused_with_pointer():
print print
print fused_with_pointer(string_array).decode('ascii') print fused_with_pointer(string_array).decode('ascii')
cdef fused_type1* fused_pointer_except_null(fused_type1 x) except NULL: cdef fused_type1* fused_pointer_except_null(fused_type1* x) except NULL:
if fused_type1 is string_t: if fused_type1 is string_t:
assert(bool(x)) assert(bool(x[0]))
else: else:
assert(x < 10) assert(x[0] < 10)
return &x return x
def test_fused_pointer_except_null(value): def test_fused_pointer_except_null(value):
""" """
...@@ -145,11 +145,14 @@ def test_fused_pointer_except_null(value): ...@@ -145,11 +145,14 @@ def test_fused_pointer_except_null(value):
AssertionError AssertionError
""" """
if isinstance(value, int): if isinstance(value, int):
print fused_pointer_except_null(<cython.int>value)[0] test_int = cython.declare(cython.int, value)
print fused_pointer_except_null(&test_int)[0]
elif isinstance(value, float): elif isinstance(value, float):
print fused_pointer_except_null(<cython.float>value)[0] test_float = cython.declare(cython.float, value)
print fused_pointer_except_null(&test_float)[0]
elif isinstance(value, bytes): elif isinstance(value, bytes):
print fused_pointer_except_null(<string_t>value)[0].decode('ascii') test_str = cython.declare(string_t, value)
print fused_pointer_except_null(&test_str)[0].decode('ascii')
include "cythonarrayutil.pxi" include "cythonarrayutil.pxi"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment