[pypy-commit] pypy faster-rstruct-2: add more tests
antocuni
pypy.commits at gmail.com
Wed May 10 19:05:25 EDT 2017
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: faster-rstruct-2
Changeset: r91226:6a63a61cf847
Date: 2017-05-10 11:32 +0200
http://bitbucket.org/pypy/pypy/changeset/6a63a61cf847/
Log: add more tests
diff --git a/rpython/rlib/rstruct/formatiterator.py b/rpython/rlib/rstruct/formatiterator.py
--- a/rpython/rlib/rstruct/formatiterator.py
+++ b/rpython/rlib/rstruct/formatiterator.py
@@ -116,7 +116,6 @@
def table2desclist(table):
items = table.items()
items.sort()
- import pdb;pdb.set_trace()
lst = [FmtDesc(key, attrs) for key, attrs in items]
return unrolling_iterable(lst)
diff --git a/rpython/rlib/rstruct/test/test_pack.py b/rpython/rlib/rstruct/test/test_pack.py
--- a/rpython/rlib/rstruct/test/test_pack.py
+++ b/rpython/rlib/rstruct/test/test_pack.py
@@ -60,6 +60,30 @@
self.check('f', 123.456)
self.check('d', 123.456789)
+ def test_pack_char(self):
+ self.check('c', 'a')
+
+ def test_pack_pad(self):
+ bigendian = self.endianess == '>'
+ fmtiter = FakeFormatIter(bigendian, None)
+ standardfmttable.pack_pad(fmtiter, 4)
+ s = fmtiter.result.build()
+ assert s == '\x00'*4
+
+ def test_pack_string(self):
+ bigendian = self.endianess == '>'
+ fmtiter = FakeFormatIter(bigendian, 'hello')
+ standardfmttable.pack_string(fmtiter, 8)
+ s = fmtiter.result.build()
+ assert s == 'hello\x00\x00\x00'
+
+ def test_pack_pascal(self):
+ bigendian = self.endianess == '>'
+ fmtiter = FakeFormatIter(bigendian, 'hello')
+ standardfmttable.pack_pascal(fmtiter, 8)
+ s = fmtiter.result.build()
+ assert s == '\x05hello\x00\x00'
+
class TestPackLittleEndian(BaseTestPack):
endianess = '<'
More information about the pypy-commit
mailing list