Cython has moved to github.
cython-devel
view tests/run/strescapes.pyx @ 1622:4f0327bdebc9
test for temp allocation bug in call
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Sat Jan 17 01:25:34 2009 -0800 (3 years ago) |
| parents | 585c7a0377b7 |
| children |
line source
1 __doc__ = u"""
3 >>> py_strings = [
4 ... b'\\x1234',
5 ... b'\\x0A12\\x0C34',
6 ... b'\\x0A57',
7 ... b'\\x0A',
8 ... b'\\'',
9 ... b"\\'",
10 ... b"\\"",
11 ... b'\\"',
12 ... b'abc\\x12def',
13 ... u'\\u1234',
14 ... u'\\U00001234',
15 ... b'\\u1234',
16 ... b'\\U00001234',
17 ... b'\\n\\r\\t',
18 ... b':>',
19 ... b'??>',
20 ... b'\\0\\0\\0',
21 ... ]
23 >>> for i, (py_string, (c_string, length)) in enumerate(zip(py_strings, c_strings)):
24 ... assert py_string == c_string, "%d: %r != %r" % (i, py_string, c_string)
25 ... assert len(py_string) == length, (
26 ... "%d: wrong length of %r, got %d, expected %d" % (
27 ... i, py_string, len(py_string), length))
28 ... assert len(c_string) == length, (
29 ... "%d: wrong length of %r, got %d, expected %d" % (
30 ... i, c_string, len(c_string), length))
32 """
34 import sys
35 if sys.version_info[0] < 3:
36 __doc__ = __doc__.replace(u" b'", u" '").replace(u' b"', u' "')
37 else:
38 __doc__ = __doc__.replace(u" u'", u" '").replace(u' u"', u' "')
40 c_strings = [
41 (b'\x1234', 3),
42 (b'\x0A12\x0C34', 6),
43 (b'\x0A57', 3),
44 (b'\x0A', 1),
45 (b'\'', 1),
46 (b"\'", 1),
47 (b"\"", 1),
48 (b'\"', 1),
49 (b'abc\x12def', 7),
50 (u'\u1234', 1),
51 (u'\U00001234', 1),
52 (b'\u1234', 6),
53 (b'\U00001234', 10),
54 (b'\n\r\t', 3),
55 (b':>', 2),
56 (b'??>', 3),
57 (b'\0\0\0', 3),
58 ]
