From: Stefan Behnel Date: Wed, 28 Oct 2009 07:57:12 +0000 (+0100) Subject: added doctest to compile test case X-Git-Tag: 0.12.alpha0~11^2~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7b50ad79c721644d65d5980c1cfcb0341cf60183;p=cython.git added doctest to compile test case --HG-- rename : tests/compile/coercearraytoptr.pyx => tests/run/coercearraytoptr.pyx --- diff --git a/tests/compile/coercearraytoptr.pyx b/tests/compile/coercearraytoptr.pyx deleted file mode 100644 index 5c5ad652..00000000 --- a/tests/compile/coercearraytoptr.pyx +++ /dev/null @@ -1,12 +0,0 @@ -cdef extern void spam(char *s) - -cdef struct Grail: - char silly[42] - -cdef void eggs(): - cdef char silly[42] - cdef Grail grail - spam(silly) - spam(grail.silly) - -eggs() diff --git a/tests/run/coercearraytoptr.pyx b/tests/run/coercearraytoptr.pyx new file mode 100644 index 00000000..fb68076b --- /dev/null +++ b/tests/run/coercearraytoptr.pyx @@ -0,0 +1,24 @@ + +cdef char* cstring = "abcdefg" + +cdef void spam(char *target): + cdef char* s = cstring + while s[0]: + target[0] = s[0] + s += 1 + target += 1 + target[0] = c'\0' + +cdef struct Grail: + char silly[42] + +def eggs(): + """ + >>> print(str(eggs()).replace("b'", "'")) + ('abcdefg', 'abcdefg') + """ + cdef char silly[42] + cdef Grail grail + spam(silly) + spam(grail.silly) + return silly, grail.silly