Sha256: 53a6adf2976cfb62f99a615a9b4f058e7382c8a7730e6ac99885f448b43e2f1f

Contents?: true

Size: 1.22 KB

Versions: 52

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.1.0

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

52 entries across 52 versions & 1 rubygems

Version Path
trackler-2.2.1.160 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.159 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.158 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.157 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.156 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.155 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.154 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.153 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.152 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.151 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.150 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.149 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.148 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.147 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.146 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.145 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.144 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.143 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.142 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py
trackler-2.2.1.141 tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py