Sha256: 40fe71a09af578aa1398acaddc93d535a380a32037feb677ff890e02eeedf60e

Contents?: true

Size: 1.51 KB

Versions: 54

Compression:

Stored size: 1.51 KB

Contents

import unittest

import rotational_cipher


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

class RotationalCipher(unittest.TestCase):
    def test_rotate_a_by_0(self):
        self.assertEqual(rotational_cipher.rotate('a', 0), 'a')

    def test_rotate_a_by_1(self):
        self.assertEqual(rotational_cipher.rotate('a', 1), 'b')

    def test_rotate_a_by_26(self):
        self.assertEqual(rotational_cipher.rotate('a', 26), 'a')

    def test_rotate_m_by_13(self):
        self.assertEqual(rotational_cipher.rotate('m', 13), 'z')

    def test_rotate_n_by_13_with_wrap_around_alphabet(self):
        self.assertEqual(rotational_cipher.rotate('n', 13), 'a')

    def test_rotate_capital_letters(self):
        self.assertEqual(rotational_cipher.rotate('OMG', 5), 'TRL')

    def test_rotate_spaces(self):
        self.assertEqual(rotational_cipher.rotate('O M G', 5), 'T R L')

    def test_rotate_numbers(self):
        self.assertEqual(
            rotational_cipher.rotate('Testing 1 2 3 testing', 4),
            'Xiwxmrk 1 2 3 xiwxmrk')

    def test_rotate_punctuation(self):
        self.assertEqual(
            rotational_cipher.rotate("Let's eat, Grandma!", 21),
            "Gzo'n zvo, Bmviyhv!")

    def test_rotate_all_letters(self):
        self.assertEqual(
            rotational_cipher.rotate("The quick brown fox jumps"
                                     " over the lazy dog.", 13),
            "Gur dhvpx oebja sbk whzcf bire gur ynml qbt.")


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

Version data entries

54 entries across 54 versions & 1 rubygems

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