Sha256: 0e307556c784382734dcf5036a7dd12fd03076b2b6409f84c89278ba7dbd5958

Contents?: true

Size: 1.99 KB

Versions: 136

Compression:

Stored size: 1.99 KB

Contents

import unittest

from atbash_cipher import decode, encode


# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.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

136 entries across 136 versions & 1 rubygems

Version Path
trackler-2.2.1.45 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.44 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.43 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.42 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.41 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.40 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.39 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.38 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.37 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.36 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.35 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.34 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.33 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.32 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.31 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.30 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.29 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.28 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.27 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.2.1.26 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py