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.8.3 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.2 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.1 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.7.0 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.44 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.43 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.42 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.41 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.40 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.39 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.38 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.37 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.36 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.35 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.34 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.33 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.32 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.31 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.30 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.6.29 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java