Skip to content

Commit 261fcc0

Browse files
committed
1 parent 83bf911 commit 261fcc0

1 file changed

Lines changed: 68 additions & 26 deletions

File tree

Lines changed: 68 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,111 @@
1-
import static org.hamcrest.CoreMatchers.*;
2-
import static org.junit.Assert.*;
3-
4-
import org.junit.Test;
51
import org.junit.Ignore;
62
import org.junit.Rule;
3+
import org.junit.Test;
74
import org.junit.rules.ExpectedException;
85

6+
import static org.junit.Assert.assertEquals;
7+
8+
/*
9+
* version: 1.1.0
10+
*/
911
public class HammingTest {
1012

1113
@Rule
12-
public ExpectedException thrown = ExpectedException.none();
13-
14+
public ExpectedException expectedException = ExpectedException.none();
15+
1416
@Test
15-
public void testNoDifferenceBetweenIdenticalStrands() {
16-
assertThat(new Hamming("A", "A").getHammingDistance(), is(0));
17+
public void testNoDistanceBetweenEmptyStrands() {
18+
assertEquals(0, new Hamming("", "").getHammingDistance());
1719
}
1820

1921
@Ignore("Remove to run test")
2022
@Test
21-
public void testHammingDistanceForSingleNucleotideStrand() {
22-
assertThat(new Hamming("A", "G").getHammingDistance(), is(1));
23+
public void testNoDistanceBetweenShortIdenticalStrands() {
24+
assertEquals(0, new Hamming("A", "A").getHammingDistance());
2325
}
2426

2527
@Ignore("Remove to run test")
2628
@Test
27-
public void testHammingDistanceForSmallStrand() {
28-
assertThat(new Hamming("AG", "CT").getHammingDistance(), is(2));
29+
public void testNoDistanceBetweenLongIdenticalStrands() {
30+
assertEquals(0, new Hamming("GGACTGA", "GGACTGA").getHammingDistance());
2931
}
3032

3133
@Ignore("Remove to run test")
3234
@Test
33-
public void testSmallHammingDistance() {
34-
assertThat(new Hamming("AT", "CT").getHammingDistance(), is(1));
35+
public void testCompleteDistanceInSingleNucleotideStrand() {
36+
assertEquals(1, new Hamming("A", "G").getHammingDistance());
3537
}
3638

3739
@Ignore("Remove to run test")
3840
@Test
39-
public void testSmallHammingDistanceInLongerStrand() {
40-
assertThat(new Hamming("GGACG", "GGTCG").getHammingDistance(), is(1));
41+
public void testCompleteDistanceInSmallStrand() {
42+
assertEquals(2, new Hamming("AG", "CT").getHammingDistance());
4143
}
4244

4345
@Ignore("Remove to run test")
4446
@Test
45-
public void testValidatesFirstStrandNotLonger() {
46-
thrown.expect(IllegalArgumentException.class);
47-
new Hamming("AAAG", "AAA");
47+
public void testSmallDistanceInSmallStrand() {
48+
assertEquals(1, new Hamming("AT", "CT").getHammingDistance());
4849
}
4950

5051
@Ignore("Remove to run test")
5152
@Test
52-
public void testValidatesOtherStrandNotLonger() {
53-
thrown.expect(IllegalArgumentException.class);
54-
new Hamming("AAA", "AAAG");
53+
public void testSmallDistanceInMediumStrand() {
54+
assertEquals(1, new Hamming("GGACG", "GGTCG").getHammingDistance());
5555
}
5656

5757
@Ignore("Remove to run test")
5858
@Test
59-
public void testLargeHammingDistance() {
60-
assertThat(new Hamming("GATACA", "GCATAA").getHammingDistance(), is(4));
59+
public void testSmallDistanceInLongStrand() {
60+
assertEquals(2, new Hamming("ACCAGGG", "ACTATGG").getHammingDistance());
6161
}
6262

6363
@Ignore("Remove to run test")
6464
@Test
65-
public void testHammingDistanceInVeryLongStrand() {
66-
assertThat(new Hamming("GGACGGATTCTG", "AGGACGGATTCT").getHammingDistance(), is(9));
65+
public void testNonUniqueCharacterInFirstStrand() {
66+
assertEquals(1, new Hamming("AGA", "AGG").getHammingDistance());
67+
}
68+
69+
@Ignore("Remove to run test")
70+
@Test
71+
public void testNonUniqueCharacterInSecondStrand() {
72+
assertEquals(1, new Hamming("AGG", "AGA").getHammingDistance());
73+
}
74+
75+
@Ignore("Remove to run test")
76+
@Test
77+
public void testSameNucleotidesInDifferentPositions() {
78+
assertEquals(2, new Hamming("TAG", "GAT").getHammingDistance());
79+
}
80+
81+
@Ignore("Remove to run test")
82+
@Test
83+
public void testLargeDistanceInPermutedStrand() {
84+
assertEquals(4, new Hamming("GATACA", "GCATAA").getHammingDistance());
85+
}
86+
87+
@Ignore("Remove to run test")
88+
@Test
89+
public void testLargeDistanceInOffByOneStrand() {
90+
assertEquals(9, new Hamming("GGACGGATTCTG", "AGGACGGATTCT").getHammingDistance());
91+
}
92+
93+
@Ignore("Remove to run test")
94+
@Test
95+
public void testValidatesFirstStrandNotLonger() {
96+
expectedException.expect(IllegalArgumentException.class);
97+
expectedException.expectMessage("leftStrand and rightStrand must be of equal length.");
98+
99+
new Hamming("AATG", "AAA");
100+
}
101+
102+
@Ignore("Remove to run test")
103+
@Test
104+
public void testValidatesSecondStrandNotLonger() {
105+
expectedException.expect(IllegalArgumentException.class);
106+
expectedException.expectMessage("leftStrand and rightStrand must be of equal length.");
107+
108+
new Hamming("ATA", "AGTG");
67109
}
68110

69111
}

0 commit comments

Comments
 (0)