Sha256: 0182acd1b50603b138660fa6e7f3b79edc0dde2a8c2cae8f7eca578a926bcd5e

Contents?: true

Size: 1.22 KB

Versions: 62

Compression:

Stored size: 1.22 KB

Contents

import unittest

from rail_fence_cipher import encode, decode


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.1

class RailFenceTests(unittest.TestCase):
    def test_encode_with_two_rails(self):
        self.assertMultiLineEqual(
            encode('XOXOXOXOXOXOXOXOXO', 2), 'XXXXXXXXXOOOOOOOOO')

    def test_encode_with_three_rails(self):
        self.assertMultiLineEqual(
            encode('WEAREDISCOVEREDFLEEATONCE', 3),
            'WECRLTEERDSOEEFEAOCAIVDEN')

    def test_encode_with_ending_in_the_middle(self):
        self.assertMultiLineEqual(encode('EXERCISES', 4), 'ESXIEECSR')

    def test_decode_with_three_rails(self):
        self.assertMultiLineEqual(
            decode('TEITELHDVLSNHDTISEIIEA', 3), 'THEDEVILISINTHEDETAILS')

    def test_decode_with_five_rails(self):
        self.assertMultiLineEqual(
            decode('EIEXMSMESAORIWSCE', 5), 'EXERCISMISAWESOME')

    def test_decode_with_six_rails(self):
        self.assertMultiLineEqual(
            decode(
                '133714114238148966225439541018335470986172518171757571896261',
                6),
            '112358132134558914423337761098715972584418167651094617711286')


if __name__ == '__main__':
    unittest.main()

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
trackler-2.2.1.107 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.106 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.105 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.104 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.103 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.102 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.101 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.100 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.99 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.98 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.97 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.96 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.95 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.94 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.93 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.92 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.91 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.90 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.89 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.88 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py