Skip to content
Snippets Groups Projects
Commit 6f0caef4 authored by morkolai's avatar morkolai
Browse files

#29 Test for vurdering av kodelengde

parent 4edf66b7
No related branches found
No related tags found
1 merge request!15Kodebok-koder
......@@ -7,7 +7,7 @@ from soitool import coder
class CoderTest(unittest.TestCase):
"""Test Coder.py."""
LEN = 2
COMBINATIONS = len(ascii_uppercase)**LEN
......@@ -19,7 +19,7 @@ class CoderTest(unittest.TestCase):
def test_get_code_set(self):
"""Test all codes are unique."""
codes = coder.get_code_set(self.COMBINATIONS, self.LEN)
self.assertAlmostEqual(self.COMBINATIONS, len(codes))
self.assertEqual(self.COMBINATIONS, len(codes))
# All possible permutations need to be inn codes
permutations_li = list(permutations(ascii_uppercase, self.LEN))
......@@ -32,6 +32,11 @@ class CoderTest(unittest.TestCase):
self.assertFalse(flag)
def test_get_code_lenght(self):
"Test return correct codelenght."
self.assertEqual(self.LEN, coder.get_code_lenght(self.COMBINATIONS))
self.assertEqual(3, coder.get_code_lenght(len(ascii_uppercase)**3))
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment