Author: Armin Rigo <[email protected]>
Branch:
Changeset: r2659:d13f78c88231
Date: 2016-04-15 18:28 +0200
http://bitbucket.org/cffi/cffi/changeset/d13f78c88231/
Log: Add a test here
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -3525,3 +3525,18 @@
d = {}
_get_common_types(d)
assert d['bool'] == '_Bool'
+
+def test_rawstring():
+ BChar = new_primitive_type("char")
+ BArray = new_array_type(new_pointer_type(BChar), 10) # char[10]
+ p = newp(BArray, "abc\x00def")
+ assert rawstring(p) == "abc\x00def\x00\x00\x00"
+ assert rawstring(p[1:6]) == "bc\x00de"
+ BWChar = new_primitive_type("wchar_t")
+ BArray = new_array_type(new_pointer_type(BWChar), 10) # wchar_t[10]
+ p = newp(BArray, u"abc\x00def")
+ assert rawstring(p) == u"abc\x00def\x00\x00\x00"
+ assert rawstring(p[1:6]) == u"bc\x00de"
+ #
+ py.test.raises(TypeError, rawstring, "foobar")
+ py.test.raises(TypeError, rawstring, p + 1)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit