|
|
@@ -1,69 +1,111 @@
|
|
1
|
|
-import static org.hamcrest.CoreMatchers.*;
|
|
2
|
|
-import static org.junit.Assert.*;
|
|
3
|
|
-
|
|
4
|
|
-import org.junit.Test;
|
|
5
|
1
|
import org.junit.Ignore;
|
|
6
|
2
|
import org.junit.Rule;
|
|
|
3
|
+import org.junit.Test;
|
|
7
|
4
|
import org.junit.rules.ExpectedException;
|
|
8
|
5
|
|
|
|
6
|
+import static org.junit.Assert.assertEquals;
|
|
|
7
|
+
|
|
|
8
|
+/*
|
|
|
9
|
+ * version: 1.1.0
|
|
|
10
|
+ */
|
|
9
|
11
|
public class HammingTest {
|
|
10
|
12
|
|
|
11
|
13
|
@Rule
|
|
12
|
|
- public ExpectedException thrown = ExpectedException.none();
|
|
13
|
|
-
|
|
|
14
|
+ public ExpectedException expectedException = ExpectedException.none();
|
|
|
15
|
+
|
|
14
|
16
|
@Test
|
|
15
|
|
- public void testNoDifferenceBetweenIdenticalStrands() {
|
|
16
|
|
- assertThat(new Hamming("A", "A").getHammingDistance(), is(0));
|
|
|
17
|
+ public void testNoDistanceBetweenEmptyStrands() {
|
|
|
18
|
+ assertEquals(0, new Hamming("", "").getHammingDistance());
|
|
17
|
19
|
}
|
|
18
|
20
|
|
|
19
|
21
|
@Ignore("Remove to run test")
|
|
20
|
22
|
@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());
|
|
23
|
25
|
}
|
|
24
|
26
|
|
|
25
|
27
|
@Ignore("Remove to run test")
|
|
26
|
28
|
@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());
|
|
29
|
31
|
}
|
|
30
|
32
|
|
|
31
|
33
|
@Ignore("Remove to run test")
|
|
32
|
34
|
@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());
|
|
35
|
37
|
}
|
|
36
|
38
|
|
|
37
|
39
|
@Ignore("Remove to run test")
|
|
38
|
40
|
@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());
|
|
41
|
43
|
}
|
|
42
|
44
|
|
|
43
|
45
|
@Ignore("Remove to run test")
|
|
44
|
46
|
@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());
|
|
48
|
49
|
}
|
|
49
|
50
|
|
|
50
|
51
|
@Ignore("Remove to run test")
|
|
51
|
52
|
@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());
|
|
55
|
55
|
}
|
|
56
|
56
|
|
|
57
|
57
|
@Ignore("Remove to run test")
|
|
58
|
58
|
@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());
|
|
61
|
61
|
}
|
|
62
|
62
|
|
|
63
|
63
|
@Ignore("Remove to run test")
|
|
64
|
64
|
@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");
|
|
67
|
109
|
}
|
|
68
|
110
|
|
|
69
|
111
|
}
|