1
exercism fetch java crypto-square

src/test/java/CryptoSquareTest.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import org.junit.Test;
import org.junit.Ignore;

import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;

public class CryptoSquareTest {

    @Test
    public void emptyPlaintextResultsInEmptyCiphertext() {
        CryptoSquare cryptoSquare = new CryptoSquare("");
        String expectedOutput = "";

        assertEquals(expectedOutput, cryptoSquare.getCiphertext());
    }

    @Ignore("Remove to run test")
    @Test
    public void lettersAreLowerCasedDuringEncryption() {
        CryptoSquare cryptoSquare = new CryptoSquare("A");
        String expectedOutput = "a";

        assertEquals(expectedOutput, cryptoSquare.getCiphertext());
    }

    @Ignore("Remove to run test")
    @Test
    public void spacesAreRemovedDuringEncryption() {
        CryptoSquare cryptoSquare = new CryptoSquare(" b ");
        String expectedOutput = "b";

        assertEquals(expectedOutput, cryptoSquare.getCiphertext());
    }

    @Ignore("Remove to run test")
    @Test
    public void punctuationIsRemovedDuringEncryption() {
        CryptoSquare cryptoSquare = new CryptoSquare("@1,%!");
        String expectedOutput = "1";

        assertEquals(expectedOutput, cryptoSquare.getCiphertext());
    }

    @Ignore("Remove to run test")
    @Test
    public void nineCharacterPlaintextResultsInThreeChunksOfThreeCharacters() {
        CryptoSquare cryptoSquare = new CryptoSquare("This is fun!");
        String expectedOutput = "tsf hiu isn";

        assertEquals(expectedOutput, cryptoSquare.getCiphertext());
    }

    @Ignore("Remove to run test")
    @Test
    public void eightCharacterPlaintextResultsInThreeChunksWithATrailingSpace() {
        CryptoSquare cryptoSquare = new CryptoSquare("Chill out.");
        String expectedOutput = "clu hlt io ";

        assertEquals(expectedOutput, cryptoSquare.getCiphertext());
    }

    @Ignore("Remove to run test")
    @Test
    public void fiftyFourCharacterPlaintextResultsInSevenChunksWithTrailingSpaces() {
        CryptoSquare cryptoSquare = new CryptoSquare("If man was meant to stay on the ground, god would have given us roots.");
        String expectedOutput = "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn  sseoau ";

        assertEquals(expectedOutput, cryptoSquare.getCiphertext());
    }
}