From 1fdca2093ac28580af4a4e204a7280a90376993d Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Thu, 18 Jun 2020 00:20:29 +0000 Subject: [PATCH] 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. --- exercises/protein-translation/tests/proteins.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/exercises/protein-translation/tests/proteins.rs b/exercises/protein-translation/tests/proteins.rs index 494aba130..828efab00 100644 --- a/exercises/protein-translation/tests/proteins.rs +++ b/exercises/protein-translation/tests/proteins.rs @@ -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![