Sha256: ca65f88da6d6b5d9f563f771f61bd50f51cdeaedbc3c69f1218f299b7ed36de4

Contents?: true

Size: 1.99 KB

Versions: 73

Compression:

Stored size: 1.99 KB

Contents

import unittest

from atbash_cipher import decode, encode


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

class AtbashCipherTest(unittest.TestCase):
    def test_encode_no(self):
        self.assertMultiLineEqual(encode("no"), "ml")

    def test_encode_yes(self):
        self.assertMultiLineEqual(encode("yes"), "bvh")

    def test_encode_OMG(self):
        self.assertMultiLineEqual(encode("OMG"), "lnt")

    def test_encode_O_M_G(self):
        self.assertMultiLineEqual(encode("O M G"), "lnt")

    def test_encode_long_word(self):
        self.assertMultiLineEqual(encode("mindblowingly"), "nrmwy oldrm tob")

    def test_encode_numbers(self):
        self.assertMultiLineEqual(
            encode("Testing, 1 2 3, testing."), "gvhgr mt123 gvhgr mt")

    def test_encode_sentence(self):
        self.assertMultiLineEqual(
            encode("Truth is fiction."), "gifgs rhurx grlm")

    def test_encode_all_things(self):
        plaintext = "The quick brown fox jumps over the lazy dog."
        ciphertext = "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"
        self.assertMultiLineEqual(encode(plaintext), ciphertext)

    def test_decode_word(self):
        self.assertMultiLineEqual(decode("vcvix rhn"), "exercism")

    def test_decode_sentence(self):
        self.assertMultiLineEqual(
            decode("zmlyh gzxov rhlug vmzhg vkkrm thglm v"),
            "anobstacleisoftenasteppingstone")

    def test_decode_numbers(self):
        self.assertMultiLineEqual(
            decode("gvhgr mt123 gvhgr mt"), "testing123testing")

    def test_decode_all_the_letters(self):
        ciphertext = "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"
        plaintext = "thequickbrownfoxjumpsoverthelazydog"
        self.assertMultiLineEqual(decode(ciphertext), plaintext)

    # additional track specific test
    def test_encode_decode(self):
        self.assertMultiLineEqual(
            decode(encode("Testing, 1 2 3, testing.")), "testing123testing")


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

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.179 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.178 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.177 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.176 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.175 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.174 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.173 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.172 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.171 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.170 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.169 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.167 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.166 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.165 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.164 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.163 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.162 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.161 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.160 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py