Skip to content

Commit

Permalink
protein-translation: Add couple of test to exercise proper decoding (#…
Browse files Browse the repository at this point in the history
…953)

Length which is not divisible by 3 should not make the test panic, but rather
return None.  That is not the case if it happens after a stop codon.
  • Loading branch information
nertpinx authored Jun 18, 2020
1 parent 7e4b3e7 commit 1fdca20
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions exercises/protein-translation/tests/proteins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ fn test_invalid_codons() {
assert!(info.of_rna("CARROT").is_none());
}

#[test]
#[ignore]
fn test_invalid_length() {
let info = proteins::parse(make_pairs());
assert!(info.of_rna("AUGUA").is_none());
}

#[test]
#[ignore]
fn test_valid_stopped_rna() {
let info = proteins::parse(make_pairs());
assert_eq!(info.of_rna("AUGUAAASDF"), Some(vec!["methionine"]));
}

// The input data constructor. Returns a list of codon, name pairs.
fn make_pairs() -> Vec<(&'static str, &'static str)> {
let grouped = vec![
Expand Down

0 comments on commit 1fdca20

Please sign in to comment.