libs
libuavcan
libuavcan
dsdl_compiler
pyuavcan
test
dsdl
test_common.py
Go to the documentation of this file.
1
#
2
# Copyright (C) 2014-2015 UAVCAN Development Team <uavcan.org>
3
#
4
# This software is distributed under the terms of the MIT License.
5
#
6
# Author: Ben Dyer <ben_dyer@mac.com>
7
# Pavel Kirienko <pavel.kirienko@zubax.com>
8
#
9
10
import
os
11
import
unittest
12
from
pyuavcan_v0.dsdl
import
common
13
14
15
class
TestCRC16FromBytes
(unittest.TestCase):
16
def
test_str
(self):
17
self.assertEqual(common.crc16_from_bytes(
'123456789'
), 0x29B1)
18
19
def
test_bytes
(self):
20
self.assertEqual(common.crc16_from_bytes(b
'123456789'
), 0x29B1)
21
22
def
test_bytearray
(self):
23
self.assertEqual(
24
common.crc16_from_bytes(bytearray(
'123456789'
,
'utf-8'
)),
25
0x29B1)
26
27
28
class
TestBytesFromCRC64
(unittest.TestCase):
29
def
test_zero
(self):
30
self.assertEqual(common.bytes_from_crc64(0),
31
b
"\x00\x00\x00\x00\x00\x00\x00\x00"
)
32
33
def
test_check_val
(self):
34
self.assertEqual(common.bytes_from_crc64(0x62EC59E3F1A4F00A),
35
b
"\x0A\xF0\xA4\xF1\xE3\x59\xEC\x62"
)
36
37
38
if
__name__ ==
'__main__'
:
39
unittest.main()
dsdl.test_common.TestCRC16FromBytes.test_str
def test_str(self)
Definition:
test_common.py:16
dsdl.test_common.TestCRC16FromBytes
Definition:
test_common.py:15
dsdl.test_common.TestBytesFromCRC64.test_zero
def test_zero(self)
Definition:
test_common.py:29
pyuavcan_v0.dsdl
Definition:
pyuavcan/pyuavcan_v0/dsdl/__init__.py:1
dsdl.test_common.TestBytesFromCRC64.test_check_val
def test_check_val(self)
Definition:
test_common.py:33
dsdl.test_common.TestCRC16FromBytes.test_bytearray
def test_bytearray(self)
Definition:
test_common.py:22
dsdl.test_common.TestCRC16FromBytes.test_bytes
def test_bytes(self)
Definition:
test_common.py:19
dsdl.test_common.TestBytesFromCRC64
Definition:
test_common.py:28
uavcan_communicator
Author(s):
autogenerated on Wed Jan 11 2023 03:59:39