Sha256: d216d06c0d5d82376a572fdea07485a9f54df3ba6379b914f6640ace8ea0c522

Contents?: true

Size: 1.16 KB

Versions: 103

Compression:

Stored size: 1.16 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
    @Test
    public void cipherCanDecode() {
        String cipherText = "aaaaaaaaaa";
        assertEquals(cipherText, cipherWithDefaultKey.decode(cipherWithDefaultKey.getKey().substring(0, 10)));
    }

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

Version data entries

103 entries across 103 versions & 1 rubygems

Version Path
trackler-2.0.6.28 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.27 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.26 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.25 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.24 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.23 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.22 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.21 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.20 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.19 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.18 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.17 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.16 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.15 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.14 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.13 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.12 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.11 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.10 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.9 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java