2024-02-05 11:52:08 +00:00
|
|
|
from ..src import helpers
|
|
|
|
from ..src.pin_log_bitwise import PIN_LOG_SIZE
|
2019-04-25 14:38:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_read_bytes_by_words():
|
|
|
|
array = b"\x04\x03\x02\x01\x08\x07\x06\x05"
|
|
|
|
n = helpers.to_int_by_words(array)
|
|
|
|
assert n == 0x0102030405060708
|
2024-02-05 11:52:08 +00:00
|
|
|
assert array == helpers.to_bytes_by_words(n, PIN_LOG_SIZE)[56:]
|
2019-04-25 14:38:56 +00:00
|
|
|
|
|
|
|
array = b"\xFF\xFF\xFF\x01\x01\x05\x09\x01"
|
|
|
|
n = helpers.to_int_by_words(array)
|
|
|
|
assert n == 0x01FFFFFF01090501
|
2024-02-05 11:52:08 +00:00
|
|
|
assert array == helpers.to_bytes_by_words(n, PIN_LOG_SIZE)[56:]
|