浏览代码

Merge pull request #768 from exercism/rna-transcription-update

rna-transcription: update to v1.0.1 tests
FridaTveit 9 年前
父节点
当前提交
1ba5522e79

+ 4
- 2
exercises/rna-transcription/src/example/java/RnaTranscription.java 查看文件

@@ -1,6 +1,6 @@
1
-public class RnaTranscription {
1
+class RnaTranscription {
2 2
 
3
-    public String transcribe(String dnaStrand) {
3
+    String transcribe(String dnaStrand) {
4 4
         StringBuilder sb = new StringBuilder();
5 5
         for (char c : dnaStrand.toCharArray()) {
6 6
             switch (c) {
@@ -21,6 +21,8 @@ public class RnaTranscription {
21 21
 
22 22
             }
23 23
         }
24
+
24 25
         return sb.toString();
25 26
     }
27
+
26 28
 }

+ 5
- 3
exercises/rna-transcription/src/main/java/RnaTranscription.java 查看文件

@@ -1,5 +1,7 @@
1
-public class RnaTranscription {
2
-    public String transcribe(String dnaStrand) {
1
+class RnaTranscription {
2
+
3
+    String transcribe(String dnaStrand) {
3 4
         throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
4 5
     }
5
-}
6
+
7
+}

+ 21
- 26
exercises/rna-transcription/src/test/java/RnaTranscriptionTest.java 查看文件

@@ -1,18 +1,18 @@
1
-import org.junit.Assert;
2 1
 import org.junit.Before;
3 2
 import org.junit.Ignore;
3
+import org.junit.Rule;
4 4
 import org.junit.Test;
5 5
 import org.junit.rules.ExpectedException;
6
-import org.junit.Rule;
7 6
 
8
-public class RnaTranscriptionTest {
7
+import static org.junit.Assert.assertEquals;
9 8
 
10
-    /*
11
-    version: 2.0.0
12
-     */
9
+/*
10
+ * version: 1.0.1
11
+ */
12
+public class RnaTranscriptionTest {
13 13
 
14 14
     @Rule
15
-    public ExpectedException thrown = ExpectedException.none();
15
+    public ExpectedException expectedException = ExpectedException.none();
16 16
 
17 17
     private RnaTranscription rnaTranscription;
18 18
 
@@ -22,61 +22,56 @@ public class RnaTranscriptionTest {
22 22
     }
23 23
 
24 24
     @Test
25
-    public void testRnaTranscriptionOfEmptyDnaIsEmptyRna() {
26
-        Assert.assertEquals("", rnaTranscription.transcribe(""));
27
-    }
28
-
29
-    @Ignore("Remove to run test")
30
-    @Test
31 25
     public void testRnaTranscriptionOfCytosineIsGuanine() {
32
-        Assert.assertEquals("G", rnaTranscription.transcribe("C"));
26
+        assertEquals("G", rnaTranscription.transcribe("C"));
33 27
     }
34 28
 
35 29
     @Ignore("Remove to run test")
36 30
     @Test
37 31
     public void testRnaTranscriptionOfGuanineIsCytosine() {
38
-        Assert.assertEquals("C", rnaTranscription.transcribe("G"));
32
+        assertEquals("C", rnaTranscription.transcribe("G"));
39 33
     }
40 34
 
41 35
     @Ignore("Remove to run test")
42 36
     @Test
43 37
     public void testRnaTranscriptionOfThymineIsAdenine() {
44
-        Assert.assertEquals("A", rnaTranscription.transcribe("T"));
38
+        assertEquals("A", rnaTranscription.transcribe("T"));
45 39
     }
46 40
 
47 41
     @Ignore("Remove to run test")
48 42
     @Test
49 43
     public void testRnaTranscriptionOfAdenineIsUracil() {
50
-        Assert.assertEquals("U", rnaTranscription.transcribe("A"));
44
+        assertEquals("U", rnaTranscription.transcribe("A"));
51 45
     }
52 46
 
53 47
     @Ignore("Remove to run test")
54 48
     @Test
55 49
     public void testRnaTranscription() {
56
-        Assert.assertEquals("UGCACCAGAAUU", rnaTranscription.transcribe("ACGTGGTCTTAA"));
50
+        assertEquals("UGCACCAGAAUU", rnaTranscription.transcribe("ACGTGGTCTTAA"));
57 51
     }
58 52
 
59 53
     @Ignore("Remove to run test")
60 54
     @Test
61 55
     public void testRnaTranscriptionOfRnaThrowsAnError() {
62
-        thrown.expect(IllegalArgumentException.class);
63
-        thrown.expectMessage("Invalid input");
56
+        expectedException.expect(IllegalArgumentException.class);
57
+        expectedException.expectMessage("Invalid input");
64 58
         rnaTranscription.transcribe("U");
65 59
     }
66 60
 
67 61
     @Ignore("Remove to run test")
68 62
     @Test
69 63
     public void testRnaTranscriptionOfInvalidInputThrowsAnError() {
70
-        thrown.expect(IllegalArgumentException.class);
71
-        thrown.expectMessage("Invalid input");
72
-        rnaTranscription.transcribe("BFV");
64
+        expectedException.expect(IllegalArgumentException.class);
65
+        expectedException.expectMessage("Invalid input");
66
+        rnaTranscription.transcribe("XXX");
73 67
     }
74 68
 
75 69
     @Ignore("Remove to run test")
76 70
     @Test
77 71
     public void testRnaTranscriptionOfPartiallyInvalidInput() {
78
-        thrown.expect(IllegalArgumentException.class);
79
-        thrown.expectMessage("Invalid input");
80
-        rnaTranscription.transcribe("GCVV");
72
+        expectedException.expect(IllegalArgumentException.class);
73
+        expectedException.expectMessage("Invalid input");
74
+        rnaTranscription.transcribe("ACGTXXXCTTAA");
81 75
     }
76
+
82 77
 }