From 604836f126075767273b05a5a9fae5a8bdf8b0e2 Mon Sep 17 00:00:00 2001 From: Sang-Heon Jeon <ekffu200098@gmail.com> Date: Sat, 9 Jan 2021 00:07:13 +0900 Subject: [PATCH] feat(from_str) : add test for checking unnecessary trailing value --- exercises/conversions/from_str.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/exercises/conversions/from_str.rs b/exercises/conversions/from_str.rs index af9eee6..70ed179 100644 --- a/exercises/conversions/from_str.rs +++ b/exercises/conversions/from_str.rs @@ -82,4 +82,16 @@ mod tests { fn missing_name_and_invalid_age() { ",one".parse::<Person>().unwrap(); } + + #[test] + #[should_panic] + fn trailing_comma() { + "John,32,".parse::<Person>().unwrap(); + } + + #[test] + #[should_panic] + fn trailing_comma_and_some_string() { + "John,32,man".parse::<Person>().unwrap(); + } }