From 7b50ad79c721644d65d5980c1cfcb0341cf60183 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 28 Oct 2009 08:57:12 +0100 Subject: [PATCH] added doctest to compile test case --HG-- rename : tests/compile/coercearraytoptr.pyx => tests/run/coercearraytoptr.pyx --- tests/compile/coercearraytoptr.pyx | 12 ------------ tests/run/coercearraytoptr.pyx | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 12 deletions(-) delete mode 100644 tests/compile/coercearraytoptr.pyx create mode 100644 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 -- 2.26.2