summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2016-04-15 18:28:03 +0200
committerArmin Rigo <arigo@tunes.org>2016-04-15 18:28:03 +0200
commit3f2b37a26557ce34540b76715a5493f5f3ee930b (patch)
tree0f45c5492ba0715041a5aaa01b81ad2135985cd6
parentf5d81838a8eb7a0108192eb5abb9410ee7c038ea (diff)
downloadcffi-3f2b37a26557ce34540b76715a5493f5f3ee930b.tar.gz
Add a test here
-rw-r--r--c/test_c.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/c/test_c.py b/c/test_c.py
index 5fc28cd..36901d2 100644
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -3525,3 +3525,18 @@ def test_get_common_types():
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)