Skip to content

Commit

Permalink
Comments and testcase.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Mar 28, 2016
1 parent 39b1a5d commit 8e7056b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bitstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def pack(fmt, *args):


def unpack(fmt, data):
"""Unpack the byte string (presumably packed by pack(fmt, ...))
"""Unpack `data` (byte string, bytearray or list of integers)
according to the given format. The result is a tuple even if it
contains exactly one item.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_bitstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_unpack(self):
unpacked = unpack('u1u1s6u7u9', b'\x3e\x82\x16')
self.assertEqual(unpacked, (0, 0, -2, 65, 22))

unpacked = unpack('u1', b'\x80')
unpacked = unpack('u1', bytearray(b'\x80'))
self.assertEqual(unpacked, (1,))

packed = b'\x00\x80\x00\x00\x00\x00\x08\x00\x00\x00'
Expand All @@ -64,7 +64,7 @@ def test_unpack(self):
unpacked = unpack('u1s6f32r43', packed)
self.assertEqual(unpacked, (0, -2, 3.75, b'\x00\xff\x00\xff\x00\xe0'))

packed = b'\x80'
packed = [0x80]
unpacked = unpack('b1', packed)
self.assertEqual(unpacked, (True,))

Expand Down

0 comments on commit 8e7056b

Please sign in to comment.