Commit 8babfd03 authored by Stefan Behnel's avatar Stefan Behnel

additional test for arrays

parent bfc918c8
......@@ -16,14 +16,42 @@ def const_charptrs():
"""
cdef object obj
cdef const_char* st = b'XYZ'
cdef const_uchar* ust = b'XYZ'
cdef const_uchar* ust = <unsigned char*>b'XYZ' # needs cast to unsigned
assert typeof(st) == "const_char *", typeof(st)
my_st = st
assert typeof(my_st) == "const_char *", typeof(my_st)
obj = my_st
assert obj == b'XYZ'
assert typeof(ust) == "const_uchar *", typeof(ust)
my_ust = ust
assert typeof(my_ust) == "const_uchar *", typeof(my_ust)
obj = my_ust
assert obj == b'XYZ'
ctypedef char mychar
ctypedef unsigned char myuchar
def const_char_arrays():
"""
>>> const_char_arrays()
"""
cdef int i
cdef object obj
cdef mychar[4] st
cdef myuchar[4] ust
i = 0
for ch in <char*>b'XYZ\0':
st[i] = ch
ust[i] = ch
i += 1
assert typeof(st) == "mychar [4]", typeof(st)
obj = st
assert obj == b'XYZ'
assert typeof(ust) == "myuchar [4]", typeof(ust)
obj = ust
assert obj == b'XYZ'
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