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

HammingTest.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import static org.hamcrest.CoreMatchers.*;
  2. import static org.junit.Assert.*;
  3. import org.junit.Test;
  4. import org.junit.Ignore;
  5. import org.junit.Rule;
  6. import org.junit.rules.ExpectedException;
  7. public class HammingTest {
  8. @Rule
  9. public ExpectedException thrown = ExpectedException.none();
  10. @Test
  11. public void testNoDifferenceBetweenIdenticalStrands() {
  12. assertThat(new Hamming("A", "A").getHammingDistance(), is(0));
  13. }
  14. @Ignore
  15. @Test
  16. public void testHammingDistanceForSingleNucleotideStrand() {
  17. assertThat(new Hamming("A", "G").getHammingDistance(), is(1));
  18. }
  19. @Ignore
  20. @Test
  21. public void testHammingDistanceForSmallStrand() {
  22. assertThat(new Hamming("AG", "CT").getHammingDistance(), is(2));
  23. }
  24. @Ignore
  25. @Test
  26. public void testSmallHammingDistance() {
  27. assertThat(new Hamming("AT", "CT").getHammingDistance(), is(1));
  28. }
  29. @Ignore
  30. @Test
  31. public void testSmallHammingDistanceInLongerStrand() {
  32. assertThat(new Hamming("GGACG", "GGTCG").getHammingDistance(), is(1));
  33. }
  34. @Ignore
  35. @Test
  36. public void testValidatesFirstStrandNotLonger() {
  37. thrown.expect(IllegalArgumentException.class);
  38. new Hamming("AAAG", "AAA");
  39. }
  40. @Ignore
  41. @Test
  42. public void testValidatesOtherStrandNotLonger() {
  43. thrown.expect(IllegalArgumentException.class);
  44. new Hamming("AAA", "AAAG");
  45. }
  46. @Ignore
  47. @Test
  48. public void testLargeHammingDistance() {
  49. assertThat(new Hamming("GATACA", "GCATAA").getHammingDistance(), is(4));
  50. }
  51. @Ignore
  52. @Test
  53. public void testHammingDistanceInVeryLongStrand() {
  54. assertThat(new Hamming("GGACGGATTCTG", "AGGACGGATTCT").getHammingDistance(), is(9));
  55. }
  56. }