lots of exercises in java... from https://github.com/exercism/java

RnaTranscriptionTest.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import org.junit.Before;
  2. import org.junit.Ignore;
  3. import org.junit.Rule;
  4. import org.junit.Test;
  5. import org.junit.rules.ExpectedException;
  6. import static org.junit.Assert.assertEquals;
  7. /*
  8. * version: 1.0.1
  9. */
  10. public class RnaTranscriptionTest {
  11. @Rule
  12. public ExpectedException expectedException = ExpectedException.none();
  13. private RnaTranscription rnaTranscription;
  14. @Before
  15. public void setUp() {
  16. rnaTranscription = new RnaTranscription();
  17. }
  18. @Test
  19. public void testRnaTranscriptionOfCytosineIsGuanine() {
  20. assertEquals("G", rnaTranscription.transcribe("C"));
  21. }
  22. @Ignore("Remove to run test")
  23. @Test
  24. public void testRnaTranscriptionOfGuanineIsCytosine() {
  25. assertEquals("C", rnaTranscription.transcribe("G"));
  26. }
  27. @Ignore("Remove to run test")
  28. @Test
  29. public void testRnaTranscriptionOfThymineIsAdenine() {
  30. assertEquals("A", rnaTranscription.transcribe("T"));
  31. }
  32. @Ignore("Remove to run test")
  33. @Test
  34. public void testRnaTranscriptionOfAdenineIsUracil() {
  35. assertEquals("U", rnaTranscription.transcribe("A"));
  36. }
  37. @Ignore("Remove to run test")
  38. @Test
  39. public void testRnaTranscription() {
  40. assertEquals("UGCACCAGAAUU", rnaTranscription.transcribe("ACGTGGTCTTAA"));
  41. }
  42. @Ignore("Remove to run test")
  43. @Test
  44. public void testRnaTranscriptionOfRnaThrowsAnError() {
  45. expectedException.expect(IllegalArgumentException.class);
  46. expectedException.expectMessage("Invalid input");
  47. rnaTranscription.transcribe("U");
  48. }
  49. @Ignore("Remove to run test")
  50. @Test
  51. public void testRnaTranscriptionOfInvalidInputThrowsAnError() {
  52. expectedException.expect(IllegalArgumentException.class);
  53. expectedException.expectMessage("Invalid input");
  54. rnaTranscription.transcribe("XXX");
  55. }
  56. @Ignore("Remove to run test")
  57. @Test
  58. public void testRnaTranscriptionOfPartiallyInvalidInput() {
  59. expectedException.expect(IllegalArgumentException.class);
  60. expectedException.expectMessage("Invalid input");
  61. rnaTranscription.transcribe("ACGTXXXCTTAA");
  62. }
  63. }