summaryrefslogtreecommitdiffstats
path: root/test/test_lifescan.py
blob: 3dc0aa66a0271081592a477b18c7dac6044a59b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: MIT
"""Tests for the LifeScan OneTouch Ultra Mini driver."""

# pylint: disable=protected-access,missing-docstring

import array

from absl.testing import absltest

from glucometerutils.support import lifescan


class TestChecksum(absltest.TestCase):
    def test_crc(self):
        self.assertEqual(
            0x41cd,
            lifescan.crc_ccitt(b'\x02\x06\x06\x03'))

    def test_crc_array(self):
        cmd_array = array.array('B', b'\x02\x06\x08\x03')
        self.assertEqual(
            0x62C2,
            lifescan.crc_ccitt(cmd_array))