Author: Antonio Cuni <[email protected]>
Branch: faster-rstruct
Changeset: r80744:7f76146cee2a
Date: 2015-11-18 09:00 +0100
http://bitbucket.org/pypy/pypy/changeset/7f76146cee2a/
Log: add a passing test for shorts
diff --git a/rpython/rlib/test/test_strstorage.py
b/rpython/rlib/test/test_strstorage.py
--- a/rpython/rlib/test/test_strstorage.py
+++ b/rpython/rlib/test/test_strstorage.py
@@ -1,6 +1,6 @@
import py
import struct
-from rpython.rtyper.lltypesystem import lltype
+from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.rlib.strstorage import str_storage_getitem
from rpython.rtyper.test.tool import BaseRtypingTest
@@ -12,13 +12,20 @@
assert self.str_storage_getitem(lltype.Signed, buf, 0) == 42
assert self.str_storage_getitem(lltype.Signed, buf, size) == 43
+ def test_short(self):
+ buf = struct.pack('@hh', 42, 43)
+ size = struct.calcsize('@h')
+ x = self.str_storage_getitem(rffi.SHORT, buf, 0)
+ assert int(x) == 42
+ x = self.str_storage_getitem(rffi.SHORT, buf, size)
+ assert int(x) == 43
+
def test_float(self):
buf = struct.pack('@dd', 12.3, 45.6)
size = struct.calcsize('@d')
assert self.str_storage_getitem(lltype.Float, buf, 0) == 12.3
assert self.str_storage_getitem(lltype.Float, buf, size) == 45.6
-
class TestDirect(BaseStrStorageTest):
def str_storage_getitem(self, TYPE, buf, offset):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit