Commit 85fea391 authored by Stefan Behnel's avatar Stefan Behnel

additional test case for union assignments

parent ea8e64b9
...@@ -39,6 +39,21 @@ cdef union int_or_float: ...@@ -39,6 +39,21 @@ cdef union int_or_float:
int n int n
double x double x
def test_union_constructor(n,x):
"""
>>> test_union_constructor(1, None)
1
>>> test_union_constructor(None, 2.0)
2.0
"""
cdef int_or_float u
if n is None:
u = int_or_float(x=x)
return u.x
else:
u = int_or_float(n=n)
return u.n
cdef struct with_pointers: cdef struct with_pointers:
bint is_integral bint is_integral
int_or_float data int_or_float data
......
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