mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-06 09:50:01 +00:00
Add test for .skip()
This commit is contained in:
parent
9963522d46
commit
48d693c1b9
2 changed files with 15 additions and 1 deletions
|
|
@ -451,7 +451,7 @@ cdef class Unpacker(object):
|
|||
else:
|
||||
self.file_like = None
|
||||
|
||||
cdef _unpack(self, bint construct):
|
||||
cdef object _unpack(self, bint construct):
|
||||
cdef int ret
|
||||
cdef object obj
|
||||
while 1:
|
||||
|
|
|
|||
|
|
@ -28,6 +28,20 @@ def test_foobar():
|
|||
k += 1
|
||||
assert k == len(b'foobar')
|
||||
|
||||
def test_foobar_skip():
|
||||
unpacker = Unpacker(read_size=3)
|
||||
unpacker.feed(b'foobar')
|
||||
assert unpacker.unpack() == ord(b'f')
|
||||
unpacker.skip()
|
||||
assert unpacker.unpack() == ord(b'o')
|
||||
unpacker.skip()
|
||||
assert unpacker.unpack() == ord(b'a')
|
||||
unpacker.skip()
|
||||
try:
|
||||
o = unpacker.unpack()
|
||||
assert 0, "should raise exception"
|
||||
except StopIteration:
|
||||
assert 1, "ok"
|
||||
|
||||
def test_maxbuffersize():
|
||||
nose.tools.assert_raises(ValueError, Unpacker, read_size=5, max_buffer_size=3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue