Author: Antonio Cuni <anto.c...@gmail.com> Branch: ffistruct Changeset: r51265:2a9dd9835199 Date: 2012-01-10 15:15 +0100 http://bitbucket.org/pypy/pypy/changeset/2a9dd9835199/
Log: add a test for converting unsigned 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,6 @@ import sys from pypy.conftest import gettestobjspace -from pypy.rlib.rarithmetic import r_uint, r_singlefloat, r_longlong +from pypy.rlib.rarithmetic import r_uint, r_singlefloat, r_longlong, r_ulonglong 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 @@ -71,6 +71,19 @@ expected = r_longlong(expected) self.check(app_types.slonglong, space.wrap(maxint32+1), expected) + def test_unsigned_longlong(self): + space = self.space + maxint64 = 9223372036854775807 # maxint64+1 does not fit into a + # longlong, but it does into a + # ulonglong + if IS_32_BIT: + # internally, the type converter always casts to signed longlongs + expected = r_longlong(-maxint64-1) + else: + # on 64 bit, ulonglong == uint (i.e., unsigned long in C terms) + expected = r_uint(maxint64+1) + self.check(app_types.ulonglong, space.wrap(maxint64+1), expected) + def test_float_and_double(self): space = self.space self.check(app_types.float, space.wrap(12.34), r_singlefloat(12.34)) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit