[pypy-commit] pypy ffistruct: add a test to convert signed long longs

antocuni noreply at buildbot.pypy.org
Thu Jan 12 14:28:21 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: ffistruct
Changeset: r51264:000bd7710f81
Date: 2012-01-10 15:08 +0100
http://bitbucket.org/pypy/pypy/changeset/000bd7710f81/

Log:	add a test to convert signed long longs

diff --git a/pypy/module/_ffi/test/test_type_converter.py b/pypy/module/_ffi/test/test_type_converter.py
--- a/pypy/module/_ffi/test/test_type_converter.py
+++ b/pypy/module/_ffi/test/test_type_converter.py
@@ -1,6 +1,7 @@
 import sys
 from pypy.conftest import gettestobjspace
-from pypy.rlib.rarithmetic import r_uint, r_singlefloat
+from pypy.rlib.rarithmetic import r_uint, r_singlefloat, r_longlong
+from pypy.rlib.libffi import IS_32_BIT
 from pypy.module._ffi.interp_ffitype import app_types, descr_new_pointer
 from pypy.module._ffi.type_converter import FromAppLevelConverter, ToAppLevelConverter
 
@@ -60,6 +61,16 @@
         self.check(app_types.char, space.wrap('a'), ord('a'))
         self.check(app_types.unichar, space.wrap(u'\u1234'), 0x1234)
 
+    def test_signed_longlong(self):
+        space = self.space
+        maxint32 = 2147483647 # we cannot really go above maxint on 64 bits
+                              # (and we would not test anything, as there long
+                              # is the same as long long)
+        expected = maxint32+1
+        if IS_32_BIT:
+            expected = r_longlong(expected)
+        self.check(app_types.slonglong, space.wrap(maxint32+1), expected)
+
     def test_float_and_double(self):
         space = self.space
         self.check(app_types.float, space.wrap(12.34), r_singlefloat(12.34))


More information about the pypy-commit mailing list