Browse files

additional test for arrays

  • Loading branch information...
1 parent bfc918c commit 8babfd03959cb7fb91c2974f73703d09bd725c2b @scoder committed Apr 25, 2012
Showing with 29 additions and 1 deletion.
  1. +29 −1 tests/run/ctypedef_char_types.pyx
View
30 tests/run/ctypedef_char_types.pyx
@@ -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'

0 comments on commit 8babfd0

Please sign in to comment.