|
|
@@ -1,38 +1,68 @@
|
|
1
|
1
|
import org.junit.Test;
|
|
|
2
|
+import org.junit.experimental.runners.Enclosed;
|
|
2
|
3
|
import org.junit.runner.RunWith;
|
|
3
|
4
|
import org.junit.runners.Parameterized;
|
|
|
5
|
+import org.junit.runners.Parameterized.Parameters;
|
|
4
|
6
|
|
|
5
|
7
|
import java.util.Arrays;
|
|
6
|
8
|
import java.util.Collection;
|
|
7
|
9
|
|
|
8
|
10
|
import static org.junit.Assert.assertEquals;
|
|
9
|
11
|
|
|
10
|
|
-@RunWith(Parameterized.class)
|
|
|
12
|
+@RunWith(Enclosed.class)
|
|
11
|
13
|
public class AtbashTest {
|
|
12
|
14
|
|
|
13
|
|
- private String input;
|
|
14
|
|
- private String expectedOutput;
|
|
15
|
|
-
|
|
16
|
|
- @Parameterized.Parameters
|
|
17
|
|
- public static Collection<Object[]> data() {
|
|
18
|
|
- return Arrays.asList(new Object[][]{
|
|
19
|
|
- {"no", "ml"},
|
|
20
|
|
- {"yes", "bvh"},
|
|
21
|
|
- {"OMG", "lnt"},
|
|
22
|
|
- {"mindblowingly", "nrmwy oldrm tob"},
|
|
23
|
|
- {"Testing, 1 2 3, testing.", "gvhgr mt123 gvhgr mt"},
|
|
24
|
|
- {"Truth is fiction.", "gifgs rhurx grlm"},
|
|
25
|
|
- {"The quick brown fox jumps over the lazy dog.", "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"}
|
|
26
|
|
- });
|
|
27
|
|
- }
|
|
|
15
|
+ @RunWith(Parameterized.class)
|
|
|
16
|
+ public static class EncodeTest {
|
|
|
17
|
+ private String input;
|
|
|
18
|
+ private String expectedOutput;
|
|
|
19
|
+
|
|
|
20
|
+ @Parameters
|
|
|
21
|
+ public static Collection<Object[]> data() {
|
|
|
22
|
+ return Arrays.asList(new Object[][] {
|
|
|
23
|
+ { "no", "ml" },
|
|
|
24
|
+ { "yes", "bvh" },
|
|
|
25
|
+ { "OMG", "lnt" },
|
|
|
26
|
+ { "mindblowingly", "nrmwy oldrm tob" },
|
|
|
27
|
+ { "Testing, 1 2 3, testing.", "gvhgr mt123 gvhgr mt" },
|
|
|
28
|
+ { "Truth is fiction.", "gifgs rhurx grlm" },
|
|
|
29
|
+ { "The quick brown fox jumps over the lazy dog.", "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt" }
|
|
|
30
|
+ });
|
|
|
31
|
+ }
|
|
|
32
|
+
|
|
|
33
|
+ public EncodeTest(String input, String expectedOutput) {
|
|
|
34
|
+ this.input = input;
|
|
|
35
|
+ this.expectedOutput = expectedOutput;
|
|
|
36
|
+ }
|
|
28
|
37
|
|
|
29
|
|
- public AtbashTest(String input, String expectedOutput) {
|
|
30
|
|
- this.input = input;
|
|
31
|
|
- this.expectedOutput = expectedOutput;
|
|
|
38
|
+ @Test
|
|
|
39
|
+ public void test() {
|
|
|
40
|
+ assertEquals(expectedOutput, Atbash.encode(input));
|
|
|
41
|
+ }
|
|
32
|
42
|
}
|
|
33
|
43
|
|
|
34
|
|
- @Test
|
|
35
|
|
- public void test() {
|
|
36
|
|
- assertEquals(expectedOutput, Atbash.encode(input));
|
|
|
44
|
+ @RunWith(Parameterized.class)
|
|
|
45
|
+ public static class DecodeTest {
|
|
|
46
|
+ private String input;
|
|
|
47
|
+ private String expectedOutput;
|
|
|
48
|
+
|
|
|
49
|
+ @Parameters
|
|
|
50
|
+ public static Collection<Object[]> data() {
|
|
|
51
|
+ return Arrays.asList(new Object[][] {
|
|
|
52
|
+ { "vcvix rhn", "exercism" },
|
|
|
53
|
+ { "zmlyh gzxov rhlug vmzhg vkkrm thglm v", "anobstacleisoftenasteppingstone" },
|
|
|
54
|
+ { "gvhgr mt123 gvhgr mt", "testing123testing" }
|
|
|
55
|
+ });
|
|
|
56
|
+ }
|
|
|
57
|
+
|
|
|
58
|
+ public DecodeTest(String input, String expectedOutput) {
|
|
|
59
|
+ this.input = input;
|
|
|
60
|
+ this.expectedOutput = expectedOutput;
|
|
|
61
|
+ }
|
|
|
62
|
+
|
|
|
63
|
+ @Test
|
|
|
64
|
+ public void test() {
|
|
|
65
|
+ assertEquals(expectedOutput, Atbash.decode(input));
|
|
|
66
|
+ }
|
|
37
|
67
|
}
|
|
38
|
68
|
}
|