Exemplo n.º 1
0
 def test_data_after_eof(self):
     txt = """:00000001FF
     :04000001aabbccdded
     """
     f = io.StringIO(txt)
     with self.assertRaisesRegex(HexFileException, 'after end of file'):
         HexFile.load(f)
Exemplo n.º 2
0
    def test_load(self):
        dummyhex = """
         :01400000aa15

         w00t
        """
        f = io.StringIO(dummyhex)
        hf = HexFile.load(f)
        self.assertEqual(1, len(hf.regions))
        self.assertEqual(0x4000, hf.regions[0].address)
        self.assertSequenceEqual(bytes.fromhex('aa'), hf.regions[0].data)
Exemplo n.º 3
0
 def test_incorrect_crc(self):
     txt = ":01400000aabb"
     f = io.StringIO(txt)
     with self.assertRaisesRegex(HexFileException, 'crc'):
         HexFile.load(f)
Exemplo n.º 4
0
 def save_load(self, hf):
     f = io.StringIO()
     hf.save(f)
     hf2 = HexFile.load(io.StringIO(f.getvalue()))
     self.assertEqual(hf, hf2)
Exemplo n.º 5
0
 def test_non_empty_eof(self):
     txt = ":04000001aabbccdded"
     f = io.StringIO(txt)
     with self.assertRaisesRegex(HexFileException, 'end of file not empty'):
         HexFile.load(f)
Exemplo n.º 6
0
 def test_startaddress(self):
     txt = ":04000005aabbccdde9"
     f = io.StringIO(txt)
     hf = HexFile.load(f)
     self.assertEqual(0xaabbccdd, hf.start_address)