From 9315da0f21c92fbaec30b5728d001ea501242c47 Mon Sep 17 00:00:00 2001 From: Chad Dougherty <crd@acm.org> Date: Sun, 12 Jul 2020 21:40:03 -0400 Subject: [PATCH] Add insufficient length test It seems to me like if we're already testing for an overly long slice, we might as well check for one that is too short as well. --- exercises/conversions/try_from_into.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exercises/conversions/try_from_into.rs b/exercises/conversions/try_from_into.rs index dbdbe00..9e452f2 100644 --- a/exercises/conversions/try_from_into.rs +++ b/exercises/conversions/try_from_into.rs @@ -127,4 +127,10 @@ mod tests { let v = vec![0, 0, 0, 0]; let _ = Color::try_from(&v[..]).unwrap(); } + #[test] + #[should_panic] + fn test_slice_insufficient_length() { + let v = vec![0, 0]; + let _ = Color::try_from(&v[..]).unwrap(); + } }