Skip to content

Commit 4f1374a

Browse files
committed
feat(from_into) : add test for checking unnecessary trailing value
1 parent 5a0521e commit 4f1374a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

exercises/conversions/from_into.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,18 @@ mod tests {
115115
assert_eq!(p.name, "John");
116116
assert_eq!(p.age, 30);
117117
}
118+
119+
#[test]
120+
fn test_trailing_comma() {
121+
let p: Person = Person::from("Mike,32,");
122+
assert_eq!(p.name, "John");
123+
assert_eq!(p.age, 30);
124+
}
125+
126+
#[test]
127+
fn test_trailing_comma_and_some_string() {
128+
let p: Person = Person::from("Mike,32,man");
129+
assert_eq!(p.name, "John");
130+
assert_eq!(p.age, 30);
131+
}
118132
}

0 commit comments

Comments
 (0)