From 3f2b37a26557ce34540b76715a5493f5f3ee930b Mon Sep 17 00:00:00 2001 From: Armin Rigo Date: Fri, 15 Apr 2016 18:28:03 +0200 Subject: Add a test here --- c/test_c.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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) -- cgit v1.2.1