Kaynağa Gözat

Update AtbashTest (#1307)

* Update AtbashTest

* Update tests

* Update tests
Lu Lechuan 8 yıl önce
ebeveyn
işleme
5606a63cca

+ 78
- 62
exercises/atbash-cipher/src/test/java/AtbashTest.java Dosyayı Görüntüle

@@ -1,73 +1,89 @@
1
+import org.junit.Before;
1 2
 import org.junit.Ignore;
2 3
 import org.junit.Test;
3
-import org.junit.experimental.runners.Enclosed;
4
-import org.junit.runner.RunWith;
5
-import org.junit.runners.Parameterized;
6
-import org.junit.runners.Parameterized.Parameters;
7
-
8
-import java.util.Arrays;
9
-import java.util.Collection;
10 4
 
11 5
 import static org.junit.Assert.assertEquals;
12 6
 
13
-@RunWith(Enclosed.class)
14 7
 public class AtbashTest {
15 8
 
16
-    @RunWith(Parameterized.class)
17
-    public static class EncodeTest {
18
-        private String plaintext;
19
-        private String ciphertext;
20
-
21
-        @Parameters(name = "{index}: expected plaintext \"{0}\" to encode to ciphertext \"{1}\".")
22
-        public static Collection<Object[]> data() {
23
-            return Arrays.asList(new Object[][]{
24
-                    {"yes", "bvh"},
25
-                    {"no", "ml"},
26
-                    {"OMG", "lnt"},
27
-                    {"O M G", "lnt"},
28
-                    {"mindblowingly", "nrmwy oldrm tob"},
29
-                    {"Testing,1 2 3, testing.", "gvhgr mt123 gvhgr mt"},
30
-                    {"Truth is fiction.", "gifgs rhurx grlm"},
31
-                    {"The quick brown fox jumps over the lazy dog.", "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"}
32
-            });
33
-        }
34
-
35
-        public EncodeTest(String plaintext, String ciphertext) {
36
-            this.plaintext = plaintext;
37
-            this.ciphertext = ciphertext;
38
-        }
39
-
40
-
41
-        @Test
42
-        public void test() {
43
-            assertEquals(ciphertext, new Atbash().encode(plaintext));
44
-        }
9
+    private Atbash atbash;
10
+
11
+    @Before
12
+    public void setup() {
13
+        atbash = new Atbash();
14
+    }
15
+
16
+    @Test
17
+    public void testEncodeYes() {
18
+        assertEquals("bvh", atbash.encode("yes"));
45 19
     }
46 20
 
47
-    @RunWith(Parameterized.class)
48
-    public static class DecodeTest {
49
-        private String ciphertext;
50
-        private String plaintext;
51
-
52
-        @Parameters(name = "{index}: expected ciphertext \"{0}\" to decode to plaintext \"{1}\".")
53
-        public static Collection<Object[]> data() {
54
-            return Arrays.asList(new Object[][]{
55
-                    {"vcvix rhn", "exercism"},
56
-                    {"zmlyh gzxov rhlug vmzhg vkkrm thglm v", "anobstacleisoftenasteppingstone"},
57
-                    {"gvhgr mt123 gvhgr mt", "testing123testing"},
58
-                    {"gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt", "thequickbrownfoxjumpsoverthelazydog"}
59
-            });
60
-        }
61
-
62
-        public DecodeTest(String ciphertext, String plaintext) {
63
-            this.ciphertext = ciphertext;
64
-            this.plaintext = plaintext;
65
-        }
66
-
67
-        @Ignore("Remove to run tests")
68
-        @Test
69
-        public void test() {
70
-            assertEquals(plaintext, new Atbash().decode(ciphertext));
71
-        }
21
+    @Ignore("Remove to run test")
22
+    @Test
23
+    public void testEncodeNo() {
24
+        assertEquals("ml", atbash.encode("no"));
72 25
     }
26
+
27
+    @Ignore("Remove to run test")
28
+    @Test
29
+    public void testEncodeOmgInCapital() {
30
+        assertEquals("lnt", atbash.encode("OMG"));
31
+    }
32
+
33
+    @Ignore("Remove to run test")
34
+    @Test
35
+    public void testEncodeOmgWithSpaces() {
36
+        assertEquals("lnt", atbash.encode("O M G"));
37
+    }
38
+
39
+    @Ignore("Remove to run test")
40
+    @Test
41
+    public void testEncodeMindBlowingly() {
42
+        assertEquals("nrmwy oldrm tob", atbash.encode("mindblowingly"));
43
+    }
44
+
45
+    @Ignore("Remove to run test")
46
+    @Test
47
+    public void testEncodeNumbers() {
48
+        assertEquals("gvhgr mt123 gvhgr mt", atbash.encode("Testing,1 2 3, testing."));
49
+    }
50
+
51
+    @Ignore("Remove to run test")
52
+    @Test
53
+    public void testEncodeDeepThought() {
54
+        assertEquals("gifgs rhurx grlm", atbash.encode("Truth is fiction."));
55
+    }
56
+
57
+    @Ignore("Remove to run test")
58
+    @Test
59
+    public void testEncodeAllTheLetters() {
60
+        assertEquals("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt",
61
+                atbash.encode("The quick brown fox jumps over the lazy dog."));
62
+    }
63
+
64
+    @Ignore("Remove to run test")
65
+    @Test
66
+    public void testDecodeExercism() {
67
+        assertEquals("exercism", atbash.decode("vcvix rhn"));
68
+    }
69
+
70
+    @Ignore("Remove to run test")
71
+    @Test
72
+    public void testDecodeASentence() {
73
+        assertEquals("anobstacleisoftenasteppingstone", atbash.decode("zmlyh gzxov rhlug vmzhg vkkrm thglm v"));
74
+    }
75
+
76
+    @Ignore("Remove to run test")
77
+    @Test
78
+    public void testDecodeNumbers() {
79
+        assertEquals("testing123testing", atbash.decode("gvhgr mt123 gvhgr mt"));
80
+    }
81
+
82
+    @Ignore("Remove to run test")
83
+    @Test
84
+    public void testDecodeAllTheLetters() {
85
+        assertEquals("thequickbrownfoxjumpsoverthelazydog",
86
+                atbash.decode("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"));
87
+    }
88
+
73 89
 }