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.180 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.179 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.178 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.177 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.176 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.175 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.174 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.173 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.172 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.171 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.170 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.169 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.167 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.166 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.165 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.164 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.163 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.162 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.161 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.2.1.160 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java