From: Robin Krens Date: Sat, 10 Feb 2024 13:53:41 +0000 (+0100) Subject: tests: added pack and unpack test X-Git-Tag: v0.0.1~51 X-Git-Url: https://robinkrens.nl/gitweb/?a=commitdiff_plain;h=5ef1572a84e6e6c7207ada35c0f17f2268fde26f;p=renesas-ra-flasher tests: added pack and unpack test --- diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..8114205 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = -vv diff --git a/tests/test_parse.py b/tests/test_parse.py index df324bf..2aedd5c 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -1,4 +1,4 @@ -from flasher.flasher import calc_sum, unpack_pkt +from flasher.flasher import calc_sum, unpack_pkt, pack_pkt import pytest def test_calc_sum(): @@ -11,3 +11,8 @@ def test_unpack(): assert unpack_pkt(b'\x81\x00\x02\x12\x00\xEC\x03') == ['0x00'] assert unpack_pkt(b'\x81\x00\x02\x13\x00\xEB\x03') == ['0x00'] +def test_pack_unpack(): + assert unpack_pkt(pack_pkt(0x13, ['0x00','0x01','0x02'])) == ['0x00', '0x01', '0x02'] + assert unpack_pkt(pack_pkt(0x34, ['0x00'])) == ['0x00'] + assert unpack_pkt(pack_pkt(0x00, ['0x00'])) == ['0x00'] + assert unpack_pkt(pack_pkt(0x12, ['0x00'])) == ['0x00']