Browse Source

add a few case to get 100% coverage

main
John-Mark Gurney 1 year ago
parent
commit
04ab6d9f83
1 changed files with 11 additions and 1 deletions
  1. +11
    -1
      shamirss.py

+ 11
- 1
shamirss.py View File

@@ -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))


Loading…
Cancel
Save