From ae4c54373fc1322eaa3a3f5b8589ad1b5c2c0bf5 Mon Sep 17 00:00:00 2001 From: Sang-Heon Jeon <ekffu200098@gmail.com> Date: Sat, 9 Jan 2021 00:08:38 +0900 Subject: [PATCH] feat(from_into) : add test for checking unnecessary trailing value --- exercises/conversions/from_into.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/exercises/conversions/from_into.rs b/exercises/conversions/from_into.rs index f24cf61..9d84174 100644 --- a/exercises/conversions/from_into.rs +++ b/exercises/conversions/from_into.rs @@ -115,4 +115,18 @@ mod tests { assert_eq!(p.name, "John"); assert_eq!(p.age, 30); } + + #[test] + fn test_trailing_comma() { + let p: Person = Person::from("Mike,32,"); + assert_eq!(p.name, "John"); + assert_eq!(p.age, 30); + } + + #[test] + fn test_trailing_comma_and_some_string() { + let p: Person = Person::from("Mike,32,man"); + assert_eq!(p.name, "John"); + assert_eq!(p.age, 30); + } }