|
1 | 1 | extern crate hamming;
|
2 | 2 |
|
| 3 | +fn process_distance_case(strand_pair: [&str; 2], expected_distance: Option<usize>) { |
| 4 | + assert_eq!( |
| 5 | + hamming::hamming_distance(strand_pair[0], strand_pair[1]), |
| 6 | + expected_distance |
| 7 | + ); |
| 8 | +} |
| 9 | + |
3 | 10 | #[test]
|
4 |
| -fn test_no_difference_between_empty_strands() { |
5 |
| - assert_eq!(hamming::hamming_distance("", ""), Some(0)); |
| 11 | +fn test_empty_strands() { |
| 12 | + process_distance_case(["", ""], Some(0)); |
6 | 13 | }
|
7 | 14 |
|
8 | 15 | #[test]
|
9 | 16 | #[ignore]
|
10 | 17 | fn test_no_difference_between_identical_strands() {
|
11 |
| - assert_eq!(hamming::hamming_distance("GGACTGA", "GGACTGA"), Some(0)); |
| 18 | + process_distance_case(["GGACTGA", "GGACTGA"], Some(0)); |
12 | 19 | }
|
13 | 20 |
|
14 | 21 | #[test]
|
@@ -40,3 +47,101 @@ fn test_first_string_is_longer() {
|
40 | 47 | fn test_second_string_is_longer() {
|
41 | 48 | assert_eq!(hamming::hamming_distance("A", "AA"), None);
|
42 | 49 | }
|
| 50 | + |
| 51 | +#[test] |
| 52 | +#[ignore] |
| 53 | +/// non-unique character in first strand |
| 54 | +fn test_nonunique_character_in_first_strand() { |
| 55 | + process_distance_case(["AAG", "AAA"], Some(1)); |
| 56 | +} |
| 57 | + |
| 58 | +#[test] |
| 59 | +#[ignore] |
| 60 | +/// identical strands |
| 61 | +fn test_identical_strands() { |
| 62 | + process_distance_case(["A", "A"], Some(0)); |
| 63 | +} |
| 64 | + |
| 65 | +#[test] |
| 66 | +#[ignore] |
| 67 | +/// complete distance in small strands |
| 68 | +fn test_complete_distance_in_small_strands() { |
| 69 | + process_distance_case(["AG", "CT"], Some(2)); |
| 70 | +} |
| 71 | + |
| 72 | +#[test] |
| 73 | +#[ignore] |
| 74 | +/// disallow first strand longer |
| 75 | +fn test_disallow_first_strand_longer() { |
| 76 | + process_distance_case(["AATG", "AAA"], None); |
| 77 | +} |
| 78 | + |
| 79 | +#[test] |
| 80 | +#[ignore] |
| 81 | +/// large distance |
| 82 | +fn test_large_distance() { |
| 83 | + process_distance_case(["GATACA", "GCATAA"], Some(4)); |
| 84 | +} |
| 85 | + |
| 86 | +#[test] |
| 87 | +#[ignore] |
| 88 | +/// long identical strands |
| 89 | +fn test_long_identical_strands() { |
| 90 | + process_distance_case(["GGACTGA", "GGACTGA"], Some(0)); |
| 91 | +} |
| 92 | + |
| 93 | +#[test] |
| 94 | +#[ignore] |
| 95 | +/// complete distance in single nucleotide strands |
| 96 | +fn test_complete_distance_in_single_nucleotide_strands() { |
| 97 | + process_distance_case(["A", "G"], Some(1)); |
| 98 | +} |
| 99 | + |
| 100 | +#[test] |
| 101 | +#[ignore] |
| 102 | +/// small distance |
| 103 | +fn test_small_distance() { |
| 104 | + process_distance_case(["GGACG", "GGTCG"], Some(1)); |
| 105 | +} |
| 106 | + |
| 107 | +#[test] |
| 108 | +#[ignore] |
| 109 | +/// non-unique character in second strand |
| 110 | +fn test_nonunique_character_in_second_strand() { |
| 111 | + process_distance_case(["AAA", "AAG"], Some(1)); |
| 112 | +} |
| 113 | + |
| 114 | +#[test] |
| 115 | +#[ignore] |
| 116 | +/// small distance in long strands |
| 117 | +fn test_small_distance_in_long_strands() { |
| 118 | + process_distance_case(["ACCAGGG", "ACTATGG"], Some(2)); |
| 119 | +} |
| 120 | + |
| 121 | +#[test] |
| 122 | +#[ignore] |
| 123 | +/// disallow second strand longer |
| 124 | +fn test_disallow_second_strand_longer() { |
| 125 | + process_distance_case(["ATA", "AGTG"], None); |
| 126 | +} |
| 127 | + |
| 128 | +#[test] |
| 129 | +#[ignore] |
| 130 | +/// small distance in small strands |
| 131 | +fn test_small_distance_in_small_strands() { |
| 132 | + process_distance_case(["AT", "CT"], Some(1)); |
| 133 | +} |
| 134 | + |
| 135 | +#[test] |
| 136 | +#[ignore] |
| 137 | +/// large distance in off-by-one strand |
| 138 | +fn test_large_distance_in_offbyone_strand() { |
| 139 | + process_distance_case(["GGACGGATTCTG", "AGGACGGATTCT"], Some(9)); |
| 140 | +} |
| 141 | + |
| 142 | +#[test] |
| 143 | +#[ignore] |
| 144 | +/// same nucleotides in different positions |
| 145 | +fn test_same_nucleotides_in_different_positions() { |
| 146 | + process_distance_case(["TAG", "GAT"], Some(2)); |
| 147 | +} |
0 commit comments