Skip to content

Commit

Permalink
Additional test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Aug 31, 2016
1 parent af5ee97 commit 10e8407
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/test_bincopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,22 @@ def test_bad_srec(self):
bincopy.pack_srec('q', 0, 0, '')
self.assertEqual(str(cm.exception), "bad type 'q'")

# unpack
# unpack too short record
with self.assertRaises(bincopy.Error) as cm:
bincopy.unpack_srec('')
self.assertEqual(str(cm.exception), "bad record ''")

# unpack bad first character
with self.assertRaises(bincopy.Error) as cm:
bincopy.unpack_srec('T0000011')
self.assertEqual(str(cm.exception), "bad record 'T0000011'")

# unpack bad type
with self.assertRaises(bincopy.Error) as cm:
bincopy.unpack_srec('S.000011')
self.assertEqual(str(cm.exception), "bad record type '.'")

# unpack bad crc
with self.assertRaises(bincopy.Error) as cm:
bincopy.unpack_srec('S1000011')
self.assertEqual(str(cm.exception), "bad crc in record 'S1000011'")
Expand Down Expand Up @@ -104,6 +111,14 @@ def test_binary(self):
self.assertEqual(binfile.as_binary(minimum_address=0,
padding=b'\x00'), fin.read())

# Exclude first byte ad readd it to test adjecent add before.
binfile.exclude(0, 1)
binfile.add_binary(b'1')
with open('tests/files/binary3.bin', 'rb') as fin:
reference = b'1' + fin.read()[1:]
self.assertEqual(binfile.as_binary(minimum_address=0,
padding=b'\x00'), reference)

# Dump with too high start address
with self.assertRaises(bincopy.Error) as cm:
binfile.as_binary(minimum_address=512)
Expand Down

0 comments on commit 10e8407

Please sign in to comment.