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: [86, 0, 0, 0, 113, 0, 0, 0, 0, 119, 0, 79, 0, 125, 0, 97, 0, 0, 73, 0, 0, 0, 119, 0]} def test_railencrypt_1(self): assert railencrypt(st='VwIOq}wa', k=3) == 'VqwO}aIw' class Test_raildecrypt(TestCase): # distances_true = {5: [0, 0, 0, 0, 0, 1, 1, 1, 1], 6: [4, 3, 2, 1, 0], 7: [3, 2, 1, 0], 8: [0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1], 9: [0, 0, 0, 0, 0, 0, 0, 0, 0], 10: [9, 0, 0, 0, 0, 1, 1, 1, 1], 12: [0, 3, 2, 1, 0], 11: [3, 2, 1, 0]} # distances_false = {5: [1, 1, 1, 1, 1, 0, 0, 0, 0], 6: [0, 0, 0, 0, 1], 7: [0, 0, 0, 1], 8: [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], 9: [32, 34, 87, 124, 65, 97, 36, 47, 82], 10: [0, 1, 1, 1, 1, 0, 0, 0, 0], 12: [1, 0, 0, 0, 1], 11: [0, 0, 0, 1]} def test_raildecrypt_1(self): assert raildecrypt(st=' R"/W$|aA', k=5) == ' "W|Aa$/R'