1
exercism fetch java run-length-encoding

src/test/java/RunLengthEncodingTest.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

public class RunLengthEncodingTest {
    private RunLengthEncoding runLengthEncoding;

    @Before
    public void setUp() {
        runLengthEncoding = new RunLengthEncoding();
    }

    @Test
    public void encodeEmpty() {
        Assert.assertEquals("", runLengthEncoding.encode(""));
    }

    @Ignore("Remove to run test")
    @Test
    public void encodeWithOnlySingleValues() {
        Assert.assertEquals("XYZ", runLengthEncoding.encode("XYZ"));
    }

    @Ignore("Remove to run test")
    @Test
    public void encodeWithNoSingleValues() {
        Assert.assertEquals(
                "2A3B4C",
                runLengthEncoding.encode("AABBBCCCC"));
    }

    @Ignore("Remove to run test")
    @Test
    public void encodeWithMixedValues() {
        Assert.assertEquals(
                "12WB12W3B24WB",
                runLengthEncoding.encode(
                        "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"));
    }

    @Ignore("Remove to run test")
    @Test
    public void encodeWithWhitespaceValues() {
        Assert.assertEquals(
                "2 hs2q q2w2 ",
                runLengthEncoding.encode("  hsqq qww  "));
    }

    @Ignore("Remove to run test")
    @Test
    public void encodeWithLowercaseValues() {
        Assert.assertEquals(
                "2a3b4c",
                runLengthEncoding.encode("aabbbcccc"));
    }

    @Ignore("Remove to run test")
    @Test
    public void decodeEmpty() {
        Assert.assertEquals("", runLengthEncoding.decode(""));
    }

    @Ignore("Remove to run test")
    @Test
    public void decodeWithOnlySingleValues() {
        Assert.assertEquals(
                "XYZ",
                runLengthEncoding.decode("XYZ"));
    }

    @Ignore("Remove to run test")
    @Test
    public void decodeWithNoSingleValues() {
        Assert.assertEquals(
                "AABBBCCCC",
                runLengthEncoding.decode("2A3B4C"));
    }

    @Ignore("Remove to run test")
    @Test
    public void decodeWithMixedValues() {
        Assert.assertEquals(
                "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB",
                runLengthEncoding.decode("12WB12W3B24WB"));
    }

    @Ignore("Remove to run test")
    @Test
    public void decodeWithWhitespaceValues() {
        Assert.assertEquals(
                "  hsqq qww  ",
                runLengthEncoding.decode("2 hs2q q2w2 "));
    }

    @Ignore("Remove to run test")
    @Test
    public void decodeWithLowercaseValues() {
        Assert.assertEquals(
                "aabbbcccc",
                runLengthEncoding.decode("2a3b4c"));
    }

    @Ignore("Remove to run test")
    @Test
    public void encodeThenDecode() {
        String inOut = "zzz ZZ  zZ";
        String encoded = runLengthEncoding.encode(inOut);
        Assert.assertEquals(inOut, runLengthEncoding.decode(encoded));
    }
}