This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
kse-02/tests/test_railfence_cipher.py

17 lines
1.2 KiB
Python

from unittest import TestCase
from benchmark.railfence_cipher import railencrypt
from benchmark.railfence_cipher import raildecrypt
class Test_railencrypt(TestCase):
# distances_true = {1: [0, 0, 0, 1, 1, 0, 0, 1], 2: [2, 1, 0, 1, 0], 3: [1, 0, 1], 4: [0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1]}
# distances_false = {1: [1, 1, 1, 0, 0, 1, 1, 0], 2: [0, 0, 1, 0, 1], 3: [0, 1, 0], 4: [126, 0, 0, 0, 110, 0, 0, 0, 0, 117, 0, 52, 0, 50, 0, 67, 0, 0, 32, 0, 0, 0, 104, 0]}
def test_railencrypt_1(self):
assert railencrypt(st='~u 4n2hC', k=3) == '~nu42C h'
class Test_raildecrypt(TestCase):
# distances_true = {5: [0, 0, 0, 1, 1, 0, 0, 1], 6: [2, 1, 0, 1, 0], 7: [1, 0, 1], 8: [0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1], 9: [0, 0, 0, 0, 0, 0, 0, 0], 10: [8, 0, 0, 1, 1, 0, 0, 1], 12: [0, 1, 0, 1], 11: [1, 0, 1, 0]}
# distances_false = {5: [1, 1, 1, 0, 0, 1, 1, 0], 6: [0, 0, 1, 0, 1], 7: [0, 1, 0], 8: [1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0], 9: [58, 96, 58, 124, 48, 73, 82, 79], 10: [0, 1, 1, 0, 0, 1, 1, 0], 12: [1, 0, 1, 0], 11: [0, 1, 0, 1]}
def test_raildecrypt_1(self):
assert raildecrypt(st=':0`|IO:R', k=3) == ':`:|0IRO'