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, 0, 1, 1, 1, 0, 0], 2: [3, 2, 1, 0, 2, 1], 3: [2, 1, 0], 4: [0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1]} # distances_false = {1: [1, 1, 1, 1, 0, 0, 0, 1, 1], 2: [0, 0, 0, 1, 0, 0], 3: [0, 0, 1], 4: [102, 0, 0, 0, 0, 0, 112, 0, 0, 0, 110, 0, 0, 0, 122, 0, 52, 0, 0, 0, 124, 0, 50, 0, 0, 0, 48, 0, 0, 0, 38, 0, 0, 0, 0, 0]} def test_railencrypt_1(self): assert railencrypt(st='fn|&2zp40', k=4) == 'fpnz4|20&' class Test_raildecrypt(TestCase): # distances_true = {5: [0, 0, 0, 0, 1, 1, 1], 6: [3, 2, 1, 0], 7: [2, 1, 0], 8: [0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1], 9: [0, 0, 0, 0, 0, 0, 0], 10: [7, 0, 0, 0, 1, 1, 1], 12: [0, 2, 1, 0], 11: [2, 1, 0]} # distances_false = {5: [1, 1, 1, 1, 0, 0, 0], 6: [0, 0, 0, 1], 7: [0, 0, 1], 8: [1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0], 9: [125, 79, 95, 32, 85, 109, 46], 10: [0, 1, 1, 1, 0, 0, 0], 12: [1, 0, 0, 1], 11: [0, 0, 1]} def test_raildecrypt_1(self): assert raildecrypt(st='}.Om_U ', k=4) == '}O_ Um.'