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.1.0.8 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.1.0.7 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.1.0.6 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.1.0.5 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.1.0.4 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.1.0.3 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.1.0.2 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.1.0.1 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.1.0.0 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.55 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.54 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.53 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.52 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.51 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.50 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.49 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.48 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.47 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.46 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java
trackler-2.0.8.45 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepOneTest.java