Parcourir la source

rna-transcription: update to v1.0.1 tests

Stuart Kent il y a 9 ans
Parent
révision
0e5cd2d8ee

+ 4
- 2
exercises/rna-transcription/src/example/java/RnaTranscription.java Voir le fichier

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

+ 5
- 3
exercises/rna-transcription/src/main/java/RnaTranscription.java Voir le fichier

1
-public class RnaTranscription {
2
-    public String transcribe(String dnaStrand) {
1
+class RnaTranscription {
2
+
3
+    String transcribe(String dnaStrand) {
3
         throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
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 Voir le fichier

1
-import org.junit.Assert;
2
 import org.junit.Before;
1
 import org.junit.Before;
3
 import org.junit.Ignore;
2
 import org.junit.Ignore;
3
+import org.junit.Rule;
4
 import org.junit.Test;
4
 import org.junit.Test;
5
 import org.junit.rules.ExpectedException;
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
     @Rule
14
     @Rule
15
-    public ExpectedException thrown = ExpectedException.none();
15
+    public ExpectedException expectedException = ExpectedException.none();
16
 
16
 
17
     private RnaTranscription rnaTranscription;
17
     private RnaTranscription rnaTranscription;
18
 
18
 
22
     }
22
     }
23
 
23
 
24
     @Test
24
     @Test
25
-    public void testRnaTranscriptionOfEmptyDnaIsEmptyRna() {
26
-        Assert.assertEquals("", rnaTranscription.transcribe(""));
27
-    }
28
-
29
-    @Ignore("Remove to run test")
30
-    @Test
31
     public void testRnaTranscriptionOfCytosineIsGuanine() {
25
     public void testRnaTranscriptionOfCytosineIsGuanine() {
32
-        Assert.assertEquals("G", rnaTranscription.transcribe("C"));
26
+        assertEquals("G", rnaTranscription.transcribe("C"));
33
     }
27
     }
34
 
28
 
35
     @Ignore("Remove to run test")
29
     @Ignore("Remove to run test")
36
     @Test
30
     @Test
37
     public void testRnaTranscriptionOfGuanineIsCytosine() {
31
     public void testRnaTranscriptionOfGuanineIsCytosine() {
38
-        Assert.assertEquals("C", rnaTranscription.transcribe("G"));
32
+        assertEquals("C", rnaTranscription.transcribe("G"));
39
     }
33
     }
40
 
34
 
41
     @Ignore("Remove to run test")
35
     @Ignore("Remove to run test")
42
     @Test
36
     @Test
43
     public void testRnaTranscriptionOfThymineIsAdenine() {
37
     public void testRnaTranscriptionOfThymineIsAdenine() {
44
-        Assert.assertEquals("A", rnaTranscription.transcribe("T"));
38
+        assertEquals("A", rnaTranscription.transcribe("T"));
45
     }
39
     }
46
 
40
 
47
     @Ignore("Remove to run test")
41
     @Ignore("Remove to run test")
48
     @Test
42
     @Test
49
     public void testRnaTranscriptionOfAdenineIsUracil() {
43
     public void testRnaTranscriptionOfAdenineIsUracil() {
50
-        Assert.assertEquals("U", rnaTranscription.transcribe("A"));
44
+        assertEquals("U", rnaTranscription.transcribe("A"));
51
     }
45
     }
52
 
46
 
53
     @Ignore("Remove to run test")
47
     @Ignore("Remove to run test")
54
     @Test
48
     @Test
55
     public void testRnaTranscription() {
49
     public void testRnaTranscription() {
56
-        Assert.assertEquals("UGCACCAGAAUU", rnaTranscription.transcribe("ACGTGGTCTTAA"));
50
+        assertEquals("UGCACCAGAAUU", rnaTranscription.transcribe("ACGTGGTCTTAA"));
57
     }
51
     }
58
 
52
 
59
     @Ignore("Remove to run test")
53
     @Ignore("Remove to run test")
60
     @Test
54
     @Test
61
     public void testRnaTranscriptionOfRnaThrowsAnError() {
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
         rnaTranscription.transcribe("U");
58
         rnaTranscription.transcribe("U");
65
     }
59
     }
66
 
60
 
67
     @Ignore("Remove to run test")
61
     @Ignore("Remove to run test")
68
     @Test
62
     @Test
69
     public void testRnaTranscriptionOfInvalidInputThrowsAnError() {
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
     @Ignore("Remove to run test")
69
     @Ignore("Remove to run test")
76
     @Test
70
     @Test
77
     public void testRnaTranscriptionOfPartiallyInvalidInput() {
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
 }