diff options
| author | Sang-Heon Jeon <ekffu200098@gmail.com> | 2021-01-09 00:07:13 +0900 |
|---|---|---|
| committer | Sang-Heon Jeon <ekffu200098@gmail.com> | 2021-01-09 00:07:13 +0900 |
| commit | 5a0521e92c80c43d6451fcc520fd68e7f56106f8 (patch) | |
| tree | b19c9ca45423b1d8b6a1facce79af1167301053e /exercises | |
| parent | 9c4614f7e6368a96de57a9ff1d0e50c88f9f331a (diff) | |
feat(from_str) : add test for checking unnecessary trailing value
Diffstat (limited to 'exercises')
| -rw-r--r-- | exercises/conversions/from_str.rs | 12 |
1 files changed, 12 insertions, 0 deletions
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(); + } } |
