Sha256: fb3018fd72c19ca71267b8b0678b52e15917c46732b42a47c9d41335e13d16c7

Contents?: true

Size: 1.2 KB

Versions: 232

Compression:

Stored size: 1.2 KB

Contents

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * Step 1: Make a simple shift cipher
 */
public class SimpleCipherStepOneTest {
    private Cipher cipherWithDefaultKey;

    @Before
    public void setup() {
        cipherWithDefaultKey = new Cipher();
    }

    /**
     * Here we take advantage of the fact that plaintext of "aaa..." doesn't output the key. This is a critical problem
     * with shift ciphers, some characters will always output the key verbatim.
     */
    @Test
    public void cipherCanEncode() {
        String cipherText = cipherWithDefaultKey.getKey().substring(0, 10);
        assertEquals(cipherText, cipherWithDefaultKey.encode("aaaaaaaaaa"));
    }

    @Ignore("Remove to run test")
    @Test
    public void cipherCanDecode() {
        String cipherText = "aaaaaaaaaa";
        assertEquals(cipherText, cipherWithDefaultKey.decode(cipherWithDefaultKey.getKey().substring(0, 10)));
    }

    @Ignore("Remove to run test")
    @Test
    public void cipherIsReversible() {
        String plainText = "abcdefghij";
        assertEquals(plainText, cipherWithDefaultKey.decode(cipherWithDefaultKey.encode(plainText)));
    }
}

Version data entries

232 entries across 232 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.118 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.117 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.116 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.115 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.114 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.113 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.111 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.110 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.109 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.108 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.107 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.106 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.105 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.104 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.103 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.102 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.101 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.100 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.99 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java