extended test case
authorStefan Behnel <scoder@users.berlios.de>
Mon, 26 Oct 2009 08:43:14 +0000 (09:43 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Mon, 26 Oct 2009 08:43:14 +0000 (09:43 +0100)
tests/run/carray_slicing.pyx

index 54f093fd60f35781726089b5b6ffe52488194e84..29ba23308b72b02149c63628b8ae6240acd9cb89 100644 (file)
@@ -17,6 +17,15 @@ def slice_charptr_decode():
             cstring[:3].decode('UTF-8'),
             cstring[:9].decode('UTF-8'))
 
+def slice_charptr_decode_unbound():
+    """
+    >>> print str(slice_charptr_decode_unbound()).replace("u'", "'")
+    ('a', 'abc', 'abcABCqtp')
+    """
+    return (bytes.decode(cstring[:1], 'UTF-8'),
+            bytes.decode(cstring[:3], 'UTF-8', 'replace'),
+            bytes.decode(cstring[:9], 'UTF-8'))
+
 def slice_charptr_decode_errormode():
     """
     >>> print str(slice_charptr_decode_errormode()).replace("u'", "'")
@@ -25,3 +34,14 @@ def slice_charptr_decode_errormode():
     return (cstring[:1].decode('UTF-8', 'strict'),
             cstring[:3].decode('UTF-8', 'replace'),
             cstring[:9].decode('UTF-8', 'unicode_escape'))
+
+def slice_charptr_for_loop():
+    """
+    >>> slice_charptr_for_loop()
+    ['a', 'b', 'c']
+    ['b', 'c', 'A', 'B']
+    ['B', 'C', 'q', 't', 'p']
+    """
+    print str([ c for c in cstring[:3] ]).replace(" b'", "'").replace("[b'", "'")
+    print str([ c for c in cstring[1:5] ]).replace(" b'", "'").replace("[b'", "'")
+    print str([ c for c in cstring[4:9] ]).replace(" b'", "'")