adds tests for crc

This commit is contained in:
Simon Albinsson
2018-04-12 15:32:43 +00:00
parent d4dc8220f7
commit ceb161c6a8
5 changed files with 20 additions and 0 deletions

2
Makefile Normal file
View File

@@ -0,0 +1,2 @@
test:
python -m unittest discover

View File

@@ -1 +1,2 @@
from .sgp30 import Sgp30
from .crc import Crc8

0
tests/__init__.py Normal file
View File

7
tests/context.py Normal file
View File

@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import sgp30

10
tests/test_crc.py Normal file
View File

@@ -0,0 +1,10 @@
from .context import sgp30
import unittest
class BasicTestSuite(unittest.TestCase):
"""Basic test cases."""
def test_absolute_truth_and_meaning(self):
self.assertEqual(sgp30.Crc8().hash([0xBE, 0xEF]), 0x92,"testing doccumentation example")
self.assertEqual(sgp30.Crc8().hash([1,144]), 76, "First half of default reading")
self.assertEqual(sgp30.Crc8().hash([0,6]), 39, "second half of default reading, ")