test for char* slices
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 15 Jan 2009 09:47:22 +0000 (01:47 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 15 Jan 2009 09:47:22 +0000 (01:47 -0800)
tests/run/slice_charptr.pyx [new file with mode: 0644]

diff --git a/tests/run/slice_charptr.pyx b/tests/run/slice_charptr.pyx
new file mode 100644 (file)
index 0000000..5f7369c
--- /dev/null
@@ -0,0 +1,11 @@
+__doc__ = """
+    >>> do_slice("abcdef", 2, 3)
+    ('c', 'cdef', 'ab', 'abcdef')
+    >>> do_slice("abcdef", 0, 5)
+    ('abcde', 'abcdef', '', 'abcdef')
+"""
+
+def do_slice(s, int i, int j):
+    cdef char* ss = s
+    return ss[i:j], ss[i:], ss[:i], ss[:]
+