-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_order.py
32 lines (27 loc) · 908 Bytes
/
test_order.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import random
import unittest
from noomnem import noomnem_decode, noomnem_encode
class TestOrdering(unittest.TestCase):
def test_reverse_order(self):
ba = bytearray(i for i in range(16))
words = noomnem_encode(ba)
print(words)
words = words[::-1]
print(words)
test = noomnem_decode(words)
self.assertEqual(bytes(ba), test)
def test_minimum_entropy(self):
ba = bytearray([0] * 16)
words = noomnem_encode(ba)
print('minimum', words)
random.shuffle(words)
test = noomnem_decode(words)
self.assertEqual(bytes(ba), test)
def test_maximum_entropy(self):
ba = bytearray([255] * 16)
words = noomnem_encode(ba)
words = words[::-1]
print('maximum', words)
random.shuffle(words)
test = noomnem_decode(words)
self.assertEqual(bytes(ba), test)