@@ -2,7 +2,7 @@ extern crate nucleotide_count as dna;
2
2
3
3
use std:: collections:: HashMap ;
4
4
5
- fn check_dna ( s : & str , pairs : & [ ( char , usize ) ] ) {
5
+ fn process_nucleotidecounts_case ( s : & str , pairs : & [ ( char , usize ) ] ) {
6
6
// The reason for the awkward code in here is to ensure that the failure
7
7
// message for assert_eq! is as informative as possible. A simpler
8
8
// solution would simply check the length of the map, and then
@@ -11,6 +11,7 @@ fn check_dna(s: &str, pairs: &[(char, usize)]) {
11
11
for & ( k, v) in pairs. iter ( ) {
12
12
assert_eq ! ( ( k, m. remove( & k) ) , ( k, Some ( v) ) ) ;
13
13
}
14
+
14
15
// may fail with a message that clearly shows all extra pairs in the map
15
16
assert_eq ! ( m. iter( ) . collect:: <Vec <( & char , & usize ) >>( ) , vec![ ] ) ;
16
17
}
@@ -58,22 +59,29 @@ fn counts_returns_result() {
58
59
59
60
#[ test]
60
61
#[ ignore]
61
- fn test_nucleotide_count_empty ( ) {
62
- check_dna ( "" , & [ ( 'A' , 0 ) , ( 'T' , 0 ) , ( 'C' , 0 ) , ( 'G' , 0 ) ] ) ;
62
+ fn test_empty_strand ( ) {
63
+ process_nucleotidecounts_case ( "" , & [ ( 'A' , 0 ) , ( 'T' , 0 ) , ( 'C' , 0 ) , ( 'G' , 0 ) ] ) ;
64
+ }
65
+
66
+ #[ test]
67
+ #[ ignore]
68
+ /// can count one nucleotide in single-character input
69
+ fn test_can_count_one_nucleotide_in_singlecharacter_input ( ) {
70
+ process_nucleotidecounts_case ( "G" , & [ ( 'A' , 0 ) , ( 'C' , 0 ) , ( 'G' , 1 ) , ( 'T' , 0 ) ] ) ;
63
71
}
64
72
65
73
#[ test]
66
74
#[ ignore]
67
- fn test_nucleotide_count_only_guanine ( ) {
68
- check_dna ( "GGGGGGGG ", & [ ( 'A' , 0 ) , ( 'T' , 0 ) , ( 'C' , 0 ) , ( 'G' , 8 ) ] ) ;
75
+ fn test_strand_with_repeated_nucleotide ( ) {
76
+ process_nucleotidecounts_case ( "GGGGGGG ", & [ ( 'A' , 0 ) , ( 'T' , 0 ) , ( 'C' , 0 ) , ( 'G' , 7 ) ] ) ;
69
77
}
70
78
71
79
#[ test]
72
80
#[ ignore]
73
- fn test_nucleotide_count_counts_all ( ) {
74
- check_dna (
75
- "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAA \
76
- GAGTGTCTGATAGCAGC ",
81
+ /// strand with multiple nucleotides
82
+ fn test_strand_with_multiple_nucleotides ( ) {
83
+ process_nucleotidecounts_case (
84
+ "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC ",
77
85
& [ ( 'A' , 20 ) , ( 'T' , 21 ) , ( 'C' , 12 ) , ( 'G' , 17 ) ] ,
78
86
) ;
79
87
}
@@ -83,3 +91,10 @@ fn test_nucleotide_count_counts_all() {
83
91
fn counts_invalid_nucleotide_results_in_err ( ) {
84
92
assert_eq ! ( dna:: nucleotide_counts( "GGXXX" ) , Err ( 'X' ) ) ;
85
93
}
94
+
95
+ #[ test]
96
+ #[ ignore]
97
+ /// strand with invalid nucleotides
98
+ fn test_strand_with_invalid_nucleotides ( ) {
99
+ assert_eq ! ( dna:: nucleotide_counts( "AGXXACT" ) , Err ( 'X' ) , ) ;
100
+ }
0 commit comments