-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHammingTest.java
More file actions
80 lines (62 loc) · 2.28 KB
/
HammingTest.java
File metadata and controls
80 lines (62 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThrows;
import org.junit.Ignore;
import org.junit.Test;
public class HammingTest {
@Test
public void testNoDistanceBetweenEmptyStrands() {
assertThat(new Hamming("", "").getHammingDistance()).isEqualTo(0);
}
@Test
public void testNoDistanceBetweenShortIdenticalStrands() {
assertThat(new Hamming("A", "A").getHammingDistance()).isEqualTo(0);
}
@Test
public void testCompleteDistanceInSingleLetterDifferentStrands() {
assertThat(new Hamming("G", "T").getHammingDistance()).isEqualTo(1);
}
@Test
public void testDistanceInLongIdenticalStrands() {
assertThat(new Hamming("GGACTGAAATCTG", "GGACTGAAATCTG").getHammingDistance()).isEqualTo(0);
}
@Test
public void testDistanceInLongDifferentStrands() {
assertThat(new Hamming("GGACGGATTCTG", "AGGACGGATTCT").getHammingDistance()).isEqualTo(9);
}
@Test
public void testValidatesFirstStrandNotLonger() {
IllegalArgumentException expected =
assertThrows(
IllegalArgumentException.class,
() -> new Hamming("AATG", "AAA"));
assertThat(expected)
.hasMessage("leftStrand and rightStrand must be of equal length.");
}
@Test
public void testValidatesSecondStrandNotLonger() {
IllegalArgumentException expected =
assertThrows(
IllegalArgumentException.class,
() -> new Hamming("ATA", "AGTG"));
assertThat(expected)
.hasMessage("leftStrand and rightStrand must be of equal length.");
}
@Test
public void testDisallowLeftEmptyStrand() {
IllegalArgumentException expected =
assertThrows(
IllegalArgumentException.class,
() -> new Hamming("", "G"));
assertThat(expected)
.hasMessage("left strand must not be empty.");
}
@Test
public void testDisallowRightEmptyStrand() {
IllegalArgumentException expected =
assertThrows(
IllegalArgumentException.class,
() -> new Hamming("G", ""));
assertThat(expected)
.hasMessage("right strand must not be empty.");
}
}