From 17e8468f5885de9d5ddec7da24ba72e42d353f00 Mon Sep 17 00:00:00 2001 From: Simon Albinsson Date: Thu, 12 Apr 2018 21:38:52 +0000 Subject: [PATCH] test: naive test of crc --- tests/test_sgp.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_sgp.py b/tests/test_sgp.py index d8623c4..5fda0fb 100644 --- a/tests/test_sgp.py +++ b/tests/test_sgp.py @@ -22,5 +22,20 @@ class SimpleReadTests(unittest.TestCase): def setUp(self): self.bus = MockSMBus() self.sgp=sgp30.sgp30.Sgp30(self.bus) + def test_read(self): self.assertEqual(self.sgp.read_measurements().data,[400,6]) + + #No real need to do this super-carefully + #or i will just be testing my own test code + #just make sure that CRC test are used, maybe.. + def test_crc_ok(self): + d=self.sgp.read_measurements() + self.assertEqual(d.crc_ok,True) + + def test_crc_fail(self): + bus=MockSMBus(break_crc=True) + sgp=sgp30.sgp30.Sgp30(bus) + d=sgp.read_measurements() + self.assertEqual(d.data,[400,6]) + self.assertEqual(d.crc_ok,False)