Skip to content

Commit 1ba5522

Browse files
authored
Merge pull request exercism#768 from exercism/rna-transcription-update
rna-transcription: update to v1.0.1 tests
2 parents 5603207 + 0e5cd2d commit 1ba5522

3 files changed

Lines changed: 30 additions & 31 deletions

File tree

exercises/rna-transcription/src/example/java/RnaTranscription.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
public class RnaTranscription {
1+
class RnaTranscription {
22

3-
public String transcribe(String dnaStrand) {
3+
String transcribe(String dnaStrand) {
44
StringBuilder sb = new StringBuilder();
55
for (char c : dnaStrand.toCharArray()) {
66
switch (c) {
@@ -21,6 +21,8 @@ public String transcribe(String dnaStrand) {
2121

2222
}
2323
}
24+
2425
return sb.toString();
2526
}
27+
2628
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
public class RnaTranscription {
2-
public String transcribe(String dnaStrand) {
1+
class RnaTranscription {
2+
3+
String transcribe(String dnaStrand) {
34
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
45
}
5-
}
6+
7+
}
Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import org.junit.Assert;
21
import org.junit.Before;
32
import org.junit.Ignore;
3+
import org.junit.Rule;
44
import org.junit.Test;
55
import org.junit.rules.ExpectedException;
6-
import org.junit.Rule;
76

8-
public class RnaTranscriptionTest {
7+
import static org.junit.Assert.assertEquals;
98

10-
/*
11-
version: 2.0.0
12-
*/
9+
/*
10+
* version: 1.0.1
11+
*/
12+
public class RnaTranscriptionTest {
1313

1414
@Rule
15-
public ExpectedException thrown = ExpectedException.none();
15+
public ExpectedException expectedException = ExpectedException.none();
1616

1717
private RnaTranscription rnaTranscription;
1818

@@ -21,62 +21,57 @@ public void setUp() {
2121
rnaTranscription = new RnaTranscription();
2222
}
2323

24-
@Test
25-
public void testRnaTranscriptionOfEmptyDnaIsEmptyRna() {
26-
Assert.assertEquals("", rnaTranscription.transcribe(""));
27-
}
28-
29-
@Ignore("Remove to run test")
3024
@Test
3125
public void testRnaTranscriptionOfCytosineIsGuanine() {
32-
Assert.assertEquals("G", rnaTranscription.transcribe("C"));
26+
assertEquals("G", rnaTranscription.transcribe("C"));
3327
}
3428

3529
@Ignore("Remove to run test")
3630
@Test
3731
public void testRnaTranscriptionOfGuanineIsCytosine() {
38-
Assert.assertEquals("C", rnaTranscription.transcribe("G"));
32+
assertEquals("C", rnaTranscription.transcribe("G"));
3933
}
4034

4135
@Ignore("Remove to run test")
4236
@Test
4337
public void testRnaTranscriptionOfThymineIsAdenine() {
44-
Assert.assertEquals("A", rnaTranscription.transcribe("T"));
38+
assertEquals("A", rnaTranscription.transcribe("T"));
4539
}
4640

4741
@Ignore("Remove to run test")
4842
@Test
4943
public void testRnaTranscriptionOfAdenineIsUracil() {
50-
Assert.assertEquals("U", rnaTranscription.transcribe("A"));
44+
assertEquals("U", rnaTranscription.transcribe("A"));
5145
}
5246

5347
@Ignore("Remove to run test")
5448
@Test
5549
public void testRnaTranscription() {
56-
Assert.assertEquals("UGCACCAGAAUU", rnaTranscription.transcribe("ACGTGGTCTTAA"));
50+
assertEquals("UGCACCAGAAUU", rnaTranscription.transcribe("ACGTGGTCTTAA"));
5751
}
5852

5953
@Ignore("Remove to run test")
6054
@Test
6155
public void testRnaTranscriptionOfRnaThrowsAnError() {
62-
thrown.expect(IllegalArgumentException.class);
63-
thrown.expectMessage("Invalid input");
56+
expectedException.expect(IllegalArgumentException.class);
57+
expectedException.expectMessage("Invalid input");
6458
rnaTranscription.transcribe("U");
6559
}
6660

6761
@Ignore("Remove to run test")
6862
@Test
6963
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");
7367
}
7468

7569
@Ignore("Remove to run test")
7670
@Test
7771
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");
8175
}
76+
8277
}

0 commit comments

Comments
 (0)