diff --git a/shamirss.py b/shamirss.py index 6a703df..e6ad412 100644 --- a/shamirss.py +++ b/shamirss.py @@ -22,6 +22,10 @@ # SUCH DAMAGE. # +# +# ls shamirss.py | entr sh -c ' date; python -m coverage run -m unittest shamirss && coverage report -m' +# + import functools import operator import secrets @@ -220,7 +224,7 @@ class TestShamirSS(unittest.TestCase): invcache = (None, ) + tuple(int(GF2p8(x) ** -1) for x in range(1, 256)) - if GF2p8._invcache != invcache: + if GF2p8._invcache != invcache: # pragma: no cover print('inv cache:', repr(invcache)) self.assertEqual(GF2p8._invcache, invcache) @@ -240,7 +244,13 @@ class TestShamirSS(unittest.TestCase): for j in range(10): self.assertEqual(powers[j], a ** j) + def test_gf2p8_errors(self): + self.assertRaises(ValueError, GF2p8, 1000) + def test_gf2p8(self): + self.assertEqual(int(GF2p8(5)), 5) + self.assertEqual(repr(GF2p8(5)), 'GF2p8(5)') + for i in range(10): a = GF2p8(random.randint(0, 255)) b = GF2p8(random.randint(0, 255))