Sha256: 70bd833d5633d4441d3ff22215a1cd018d478068f576ca4ed7e9571f5cc535a7

Contents?: true

Size: 1.43 KB

Versions: 105

Compression:

Stored size: 1.43 KB

Contents

import unittest

from atbash_cipher import decode, encode


class AtbashCipherTest(unittest.TestCase):

    def test_encode_no(self):
        self.assertMultiLineEqual("ml", encode("no"))

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

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

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

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

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

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

    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(ciphertext, encode(plaintext))

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

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


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

Version data entries

105 entries across 105 versions & 1 rubygems

Version Path
trackler-2.0.8.4 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.8.3 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.8.2 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.8.1 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.7.0 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.44 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.43 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.42 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.41 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.40 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.39 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.38 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.37 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.36 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.35 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.34 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.33 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.32 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.31 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py
trackler-2.0.6.30 tracks/python/exercises/atbash-cipher/atbash_cipher_test.py