Sha256: 9e35b71d71caa488726fdfbb8c67a72a4d73ae30cf07552f08a640e1ca4eb67e
Contents?: true
Size: 1.69 KB
Versions: 148
Compression:
Stored size: 1.69 KB
Contents
import org.scalatest.{Matchers, FunSuite} /** @version created manually **/ class CipherTest extends FunSuite with Matchers { test("Random key cipher - can encode/decode") { // Here we take advantage of the fact that plaintext of "aaa..." // outputs the key. This is a critical problem with shift ciphers, some // characters will always output the key verbatim. val cipher = Cipher(None) cipher.encode("aaaaaaaaaa") should be (cipher.key.substring(0, 10)) cipher.decode(cipher.key.substring(0, 10)) should be ("aaaaaaaaaa") } test("Invalid key - contains caps") { pending intercept[IllegalArgumentException] { Cipher(Some("ABCD")) } } test("Invalid key - contains numerics") { pending intercept[IllegalArgumentException] { Cipher(Some("123")) } } test("Invalid key - is empty") { pending intercept[IllegalArgumentException] { Cipher(Some("")) } } test("Substitution cipher - can encode") { pending Cipher(Some("abcdefghij")).encode("aaaaaaaaaa") should be ("abcdefghij") } test("Substitution cipher - can decode") { pending Cipher(Some("abcdefghij")).decode("abcdefghij") should be ("aaaaaaaaaa") } test("Substitution cipher - is reversible") { pending val cipher = Cipher(Some("abcdefghij")) cipher.decode(cipher.encode("abcdefghij")) should be ("abcdefghij") } test("Substitution cipher - can double shift") { pending val cipher = Cipher(Some("iamapandabear")) cipher.encode("iamapandabear") should be ("qayaeaagaciai") } test("Substitution cipher - can wrap") { pending Cipher(Some("abcdefghij")).encode("zzzzzzzzzz") should be ("zabcdefghi") } }
Version data entries
148 entries across 148 versions & 1 rubygems