From ceb161c6a8fc703914d25d6761ea2d95a87e7355 Mon Sep 17 00:00:00 2001 From: Simon Albinsson Date: Thu, 12 Apr 2018 15:32:43 +0000 Subject: [PATCH] adds tests for crc --- Makefile | 2 ++ sgp30/__init__.py | 1 + tests/__init__.py | 0 tests/context.py | 7 +++++++ tests/test_crc.py | 10 ++++++++++ 5 files changed, 20 insertions(+) create mode 100644 Makefile create mode 100644 tests/__init__.py create mode 100644 tests/context.py create mode 100644 tests/test_crc.py diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b67626b --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +test: + python -m unittest discover diff --git a/sgp30/__init__.py b/sgp30/__init__.py index 0bc4a62..3e9f28f 100644 --- a/sgp30/__init__.py +++ b/sgp30/__init__.py @@ -1 +1,2 @@ from .sgp30 import Sgp30 +from .crc import Crc8 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/context.py b/tests/context.py new file mode 100644 index 0000000..1db7e6f --- /dev/null +++ b/tests/context.py @@ -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 diff --git a/tests/test_crc.py b/tests/test_crc.py new file mode 100644 index 0000000..508162f --- /dev/null +++ b/tests/test_crc.py @@ -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, ") +