Explorar el Código

Added files and updated config.

Logan Stucki hace 9 años
padre
commit
e7481091e3

+ 5
- 0
config.json Ver fichero

@@ -136,6 +136,11 @@
136 136
       "topics": []
137 137
     },
138 138
     {
139
+      "slug": "run-time-encoding",
140
+      "difficulty": 5,
141
+      "topics": []
142
+    },
143
+    {
139 144
       "slug": "word-count",
140 145
       "difficulty": 5,
141 146
       "topics": []

+ 17
- 0
exercises/run-length-encoding/build.gradle Ver fichero

@@ -0,0 +1,17 @@
1
+apply plugin: "java"
2
+apply plugin: "eclipse"
3
+apply plugin: "idea"
4
+
5
+repositories {
6
+    mavenCentral()
7
+}
8
+
9
+dependencies {
10
+    testCompile "junit:junit:4.12"
11
+}
12
+test {
13
+    testLogging {
14
+        exceptionFormat = 'full'
15
+        events = ["passed", "failed", "skipped"]
16
+    }
17
+}

+ 9
- 0
exercises/run-length-encoding/src/example/java/RunLengthEncoding.java Ver fichero

@@ -0,0 +1,9 @@
1
+public class RunLengthEncoding {
2
+    public String encode(String input) {
3
+        throw new UnsupportedOperationException("Method has not been implemented yet.");
4
+    }
5
+
6
+    public String decode(String input) {
7
+        throw new UnsupportedOperationException("Method has not been implemented yet.");
8
+    }
9
+}

+ 9
- 0
exercises/run-length-encoding/src/main/java/RunLengthEncoding.java Ver fichero

@@ -0,0 +1,9 @@
1
+public class RunLengthEncoding {
2
+    public String encode(String input) {
3
+        throw new UnsupportedOperationException("Method has not been implemented yet.");
4
+    }
5
+
6
+    public String decode(String input) {
7
+        throw new UnsupportedOperationException("Method has not been implemented yet.");
8
+    }
9
+}

+ 79
- 0
exercises/run-length-encoding/src/test/java/RunLengthEncodingTest.java Ver fichero

@@ -0,0 +1,79 @@
1
+import org.junit.Assert;
2
+import org.junit.Before;
3
+import org.junit.Ignore;
4
+import org.junit.Test;
5
+
6
+public class RunLengthEncodingTest {
7
+    private RunLengthEncoding runLengthEncoding;
8
+
9
+    @Before
10
+    public void setUp() {
11
+        runLengthEncoding = new RunLengthEncoding();
12
+    }
13
+
14
+    @Test
15
+    public void encodeEmpty() {
16
+        Assert.assertEquals("", runLengthEncoding.encode(""));
17
+    }
18
+
19
+    @Test
20
+    public void decodeEmpty() {
21
+        Assert.assertEquals("", runLengthEncoding.decode(""));
22
+    }
23
+
24
+    @Ignore("Remove to run test")
25
+    @Test
26
+    public void encodeWithOnlySingleValues() {
27
+        Assert.assertEquals("XYZ", runLengthEncoding.encode("XYZ"));
28
+    }
29
+
30
+    @Ignore("Remove to run test")
31
+    @Test
32
+    public void decodeWithOnlySingleValues() {
33
+        Assert.assertEquals("XYZ", runLengthEncoding.decode("XYZ"));
34
+    }
35
+
36
+    @Ignore("Remove to run test")
37
+    @Test
38
+    public void encodeWithMixedValues() {
39
+        Assert.assertEquals("12WB12W3B24WB", runLengthEncoding.encode("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"));
40
+    }
41
+
42
+    @Ignore("Remove to run test")
43
+    @Test
44
+    public void decodeWithMixedValues() {
45
+        Assert.assertEquals("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB", runLengthEncoding.decode("12WB12W3B24WB"));
46
+    }
47
+
48
+    @Ignore("Remove to run test")
49
+    @Test
50
+    public void encodeWithWhitespaceValues() {
51
+        Assert.assertEquals("2 hs2q q2w2 ", runLengthEncoding.encode("  hsqq qww  "));
52
+    }
53
+
54
+    @Ignore("Remove to run test")
55
+    @Test
56
+    public void decodeWithWhitespaceValues() {
57
+        Assert.assertEquals("  hsqq qww  ", runLengthEncoding.decode("2 hs2q q2w2 "));
58
+    }
59
+
60
+    @Ignore("Remove to run test")
61
+    @Test
62
+    public void encodeWithLowercaseValues() {
63
+        Assert.assertEquals("2a3b4c", runLengthEncoding.encode("aabbbcccc"));
64
+    }
65
+
66
+    @Ignore("Remove to run test")
67
+    @Test
68
+    public void decodeWithLowercaseValues() {
69
+        Assert.assertEquals("aabbbcccc", runLengthEncoding.decode("2a3b4c"));
70
+    }
71
+
72
+    @Ignore("Remove to run test")
73
+    @Test
74
+    public void encodeThenDecode() {
75
+        String inOut = "zzz ZZ  zZ";
76
+        String encoded = runLengthEncoding.encode(inOut);
77
+        Assert.assertEquals(inOut, runLengthEncoding.decode(encoded));
78
+    }
79
+}