diff options
| author | Christoph Berg <myon@debian.org> | 2020-03-31 17:57:07 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2020-03-31 17:57:07 +0200 |
| commit | c2bdd8f8d96bf5329672163cc0905a22589d26d3 (patch) | |
| tree | 76ce2d78c98a958f97dfb6128fee9c529a2a55aa /tests/unit/test_yaesu_clone.py | |
| parent | b255867dd3e05fff714c5d3325c02596bf5854c8 (diff) | |
New upstream version 20200227+py3+20200213upstream/20200227+py3+20200213
Diffstat (limited to 'tests/unit/test_yaesu_clone.py')
| -rw-r--r-- | tests/unit/test_yaesu_clone.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/unit/test_yaesu_clone.py b/tests/unit/test_yaesu_clone.py new file mode 100644 index 0000000..869c3b5 --- /dev/null +++ b/tests/unit/test_yaesu_clone.py @@ -0,0 +1,41 @@ +from builtins import bytes +import unittest + +from chirp.drivers import yaesu_clone +from chirp import memmap + + +class TestYaesuChecksum(unittest.TestCase): + def _test_checksum(self, mmap): + cs = yaesu_clone.YaesuChecksum(0, 2, 3) + + self.assertEqual(42, cs.get_existing(mmap)) + self.assertEqual(0x8A, cs.get_calculated(mmap)) + try: + mmap = mmap.get_byte_compatible() + mmap[0] = 3 + except AttributeError: + # str or bytes + try: + # str + mmap = memmap.MemoryMap('\x03' + mmap[1:]) + except TypeError: + # bytes + mmap = memmap.MemoryMapBytes(b'\x03' + mmap[1:]) + + cs.update(mmap) + self.assertEqual(95, cs.get_calculated(mmap)) + + def test_with_MemoryMap(self): + mmap = memmap.MemoryMap('...\x2A') + self._test_checksum(mmap) + + def test_with_MemoryMapBytes(self): + mmap = memmap.MemoryMapBytes(bytes(b'...\x2A')) + self._test_checksum(mmap) + + def test_with_bytes(self): + self._test_checksum(b'...\x2A') + + def test_with_str(self): + self._test_checksum('...\x2A') |
