mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-10 11:10:26 +02:00
Merge pull request #622 from lntuition/conversions_more_utc
feat(conversions): Add more unit tests to `from_str` and `from_into` exercises.
This commit is contained in:
commit
0d65753fdb
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user