Skip to content

Commit 5a0521e

Browse files
committed
feat(from_str) : add test for checking unnecessary trailing value
1 parent 9c4614f commit 5a0521e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

exercises/conversions/from_str.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,16 @@ mod tests {
8282
fn missing_name_and_invalid_age() {
8383
",one".parse::<Person>().unwrap();
8484
}
85+
86+
#[test]
87+
#[should_panic]
88+
fn trailing_comma() {
89+
"John,32,".parse::<Person>().unwrap();
90+
}
91+
92+
#[test]
93+
#[should_panic]
94+
fn trailing_comma_and_some_string() {
95+
"John,32,man".parse::<Person>().unwrap();
96+
}
8597
}

0 commit comments

Comments
 (0)