Skip to content

Commit 1fdca20

Browse files
authored
protein-translation: Add couple of test to exercise proper decoding (#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.
1 parent 7e4b3e7 commit 1fdca20

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

exercises/protein-translation/tests/proteins.rs

+14
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ fn test_invalid_codons() {
108108
assert!(info.of_rna("CARROT").is_none());
109109
}
110110

111+
#[test]
112+
#[ignore]
113+
fn test_invalid_length() {
114+
let info = proteins::parse(make_pairs());
115+
assert!(info.of_rna("AUGUA").is_none());
116+
}
117+
118+
#[test]
119+
#[ignore]
120+
fn test_valid_stopped_rna() {
121+
let info = proteins::parse(make_pairs());
122+
assert_eq!(info.of_rna("AUGUAAASDF"), Some(vec!["methionine"]));
123+
}
124+
111125
// The input data constructor. Returns a list of codon, name pairs.
112126
fn make_pairs() -> Vec<(&'static str, &'static str)> {
113127
let grouped = vec![

0 commit comments

Comments
 (0)