[pypy-svn] r50993 - in pypy/dist/pypy/module/_rawffi: . test

fijal at codespeak.net fijal at codespeak.net
Thu Jan 24 20:57:08 CET 2008


Author: fijal
Date: Thu Jan 24 20:57:08 2008
New Revision: 50993

Modified:
   pypy/dist/pypy/module/_rawffi/interp_rawffi.py
   pypy/dist/pypy/module/_rawffi/test/test__rawffi.py
Log:
Map unicode to 4 byte. Obscure, platform dependant test. Will at least explode
when things will not fit.


Modified: pypy/dist/pypy/module/_rawffi/interp_rawffi.py
==============================================================================
--- pypy/dist/pypy/module/_rawffi/interp_rawffi.py	(original)
+++ pypy/dist/pypy/module/_rawffi/interp_rawffi.py	Thu Jan 24 20:57:08 2008
@@ -30,7 +30,7 @@
     'b' : ffi_type_schar,
     'B' : ffi_type_uchar,
     'h' : ffi_type_sshort,
-    'u' : ffi_type_ushort, # XXX alias for wide-character
+    'u' : ffi_type_uint, # XXX think deeper how to map it properly
     'H' : ffi_type_ushort,
     'i' : ffi_type_sint,
     'I' : ffi_type_uint,

Modified: pypy/dist/pypy/module/_rawffi/test/test__rawffi.py
==============================================================================
--- pypy/dist/pypy/module/_rawffi/test/test__rawffi.py	(original)
+++ pypy/dist/pypy/module/_rawffi/test/test__rawffi.py	Thu Jan 24 20:57:08 2008
@@ -500,9 +500,17 @@
     def test_wide_char(self):
         import _rawffi
         A = _rawffi.Array('u')
-        a = A(1)
+        a = A(3)
         a[0] = u'x'
+        a[1] = u'y'
+        a[2] = u'z'
         assert a[0] == u'x'
+        b = _rawffi.Array('c').fromaddress(a.buffer, 38)
+        assert b[0] == 'x'
+        assert b[1] == '\x00'
+        assert b[2] == '\x00'
+        assert b[3] == '\x00'
+        assert b[4] == 'y'
         a.free()
 
     def test_truncate(self):



More information about the Pypy-commit mailing list