Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/nucleotide-count/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[package]
name = "nucleotide-count"
version = "0.0.0"
version = "1.3.0"
33 changes: 24 additions & 9 deletions exercises/nucleotide-count/tests/nucleotide-count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate nucleotide_count as dna;

use std::collections::HashMap;

fn check_dna(s: &str, pairs: &[(char, usize)]) {
fn process_nucleotidecounts_case(s: &str, pairs: &[(char, usize)]) {
// The reason for the awkward code in here is to ensure that the failure
// message for assert_eq! is as informative as possible. A simpler
// solution would simply check the length of the map, and then
Expand All @@ -11,6 +11,7 @@ fn check_dna(s: &str, pairs: &[(char, usize)]) {
for &(k, v) in pairs.iter() {
assert_eq!((k, m.remove(&k)), (k, Some(v)));
}

// may fail with a message that clearly shows all extra pairs in the map
assert_eq!(m.iter().collect::<Vec<(&char, &usize)>>(), vec![]);
}
Expand Down Expand Up @@ -58,22 +59,29 @@ fn counts_returns_result() {

#[test]
#[ignore]
fn test_nucleotide_count_empty() {
check_dna("", &[('A', 0), ('T', 0), ('C', 0), ('G', 0)]);
fn test_empty_strand() {
process_nucleotidecounts_case("", &[('A', 0), ('T', 0), ('C', 0), ('G', 0)]);
}

#[test]
#[ignore]
/// can count one nucleotide in single-character input
fn test_can_count_one_nucleotide_in_singlecharacter_input() {
process_nucleotidecounts_case("G", &[('A', 0), ('C', 0), ('G', 1), ('T', 0)]);
}

#[test]
#[ignore]
fn test_nucleotide_count_only_guanine() {
check_dna("GGGGGGGG", &[('A', 0), ('T', 0), ('C', 0), ('G', 8)]);
fn test_strand_with_repeated_nucleotide() {
process_nucleotidecounts_case("GGGGGGG", &[('A', 0), ('T', 0), ('C', 0), ('G', 7)]);
}

#[test]
#[ignore]
fn test_nucleotide_count_counts_all() {
check_dna(
"AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAA\
GAGTGTCTGATAGCAGC",
/// strand with multiple nucleotides
fn test_strand_with_multiple_nucleotides() {
process_nucleotidecounts_case(
"AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC",
&[('A', 20), ('T', 21), ('C', 12), ('G', 17)],
);
}
Expand All @@ -83,3 +91,10 @@ fn test_nucleotide_count_counts_all() {
fn counts_invalid_nucleotide_results_in_err() {
assert_eq!(dna::nucleotide_counts("GGXXX"), Err('X'));
}

#[test]
#[ignore]
/// strand with invalid nucleotides
fn test_strand_with_invalid_nucleotides() {
assert_eq!(dna::nucleotide_counts("AGXXACT"), Err('X'),);
}