test: added test for unpack packets
[renesas-ra-flasher] / tests / test_parse.py
1 from flasher.flasher import calc_sum, unpack_pkt
2 import pytest
3
4 def test_calc_sum():
5     assert calc_sum(0x12, ['0x00']) == (0, 0x2, 0xEC)
6     assert calc_sum(0x34, ['0x00']) == (0, 0x2, 0xCA)
7     assert calc_sum(0x00, ['0x00']) == (0, 0x02, 0xFE)
8
9 def test_unpack():
10     assert unpack_pkt(b'\x81\x00\x02\x00\x00\xFE\x03') == ['0x00']
11     assert unpack_pkt(b'\x81\x00\x02\x12\x00\xEC\x03') == ['0x00']
12     assert unpack_pkt(b'\x81\x00\x02\x13\x00\xEB\x03') == ['0x00']
13