-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_run_length.py
More file actions
executable file
·39 lines (27 loc) · 1.13 KB
/
test_run_length.py
File metadata and controls
executable file
·39 lines (27 loc) · 1.13 KB
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
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import unittest
from cryptography.run_length_encoding import decode, encode
class WordCountTests(unittest.TestCase):
def test_encode(self):
self.assertMultiLineEqual("2A3B4C", encode("AABBBCCCC"))
def test_decode(self):
self.assertMultiLineEqual("AABBBCCCC", decode("2A3B4C"))
def test_encode_with_single(self):
self.assertMultiLineEqual(
"12WB12W3B24WB",
encode("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"),
)
def test_decode_with_single(self):
self.assertMultiLineEqual(
"WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB",
decode("12WB12W3B24WB"),
)
def test_combination(self):
self.assertMultiLineEqual("zzz ZZ zZ", decode(encode("zzz ZZ zZ")))
def test_encode_unicode_s(self):
self.assertMultiLineEqual("⏰3⚽2⭐⏰", encode("⏰⚽⚽⚽⭐⭐⏰"))
def test_decode_unicode(self):
self.assertMultiLineEqual("⏰⚽⚽⚽⭐⭐⏰", decode("⏰3⚽2⭐⏰"))
if __name__ == "__main__":
unittest.main()