Skip to content

Commit f9b5230

Browse files
porcelijnhdoordt
authored andcommitted
Add negative test case (invalid input -> Err result)
1 parent 6a63856 commit f9b5230

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • exercises/05_ticket_v2/13_try_from/src

exercises/05_ticket_v2/13_try_from/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ mod tests {
2323

2424
let status = Status::try_from("Done".to_string()).unwrap();
2525
assert_eq!(status, Status::Done);
26+
27+
let empty = String::new();
28+
assert!(Status::try_from(empty).is_err());
29+
30+
let invalid = "InValid".to_string();
31+
assert!(Status::try_from(invalid).is_err());
2632
}
2733

2834
#[test]
@@ -35,5 +41,8 @@ mod tests {
3541

3642
let status = Status::try_from("done").unwrap();
3743
assert_eq!(status, Status::Done);
44+
45+
assert!(Status::try_from("").is_err());
46+
assert!(Status::try_from("invalid").is_err());
3847
}
3948
}

0 commit comments

Comments
 (0)