Check the implementation of Display in the tests.
authorLukeMathWalker <20745048+LukeMathWalker@users.noreply.github.com>
Tue, 14 May 2024 08:03:45 +0000 (10:03 +0200)
committerLukeMathWalker <20745048+LukeMathWalker@users.noreply.github.com>
Tue, 14 May 2024 08:03:45 +0000 (10:03 +0200)
exercises/05_ticket_v2/09_error_trait/src/lib.rs

index 53dd114..ca89efc 100644 (file)
@@ -95,5 +95,11 @@ mod tests {
         assert_eq!(ticket.description, "Description not provided");
     }
 
+    #[test]
+    fn display_is_correctly_implemented() {
+        let ticket = Ticket::new("".into(), valid_description(), Status::ToDo);
+        assert_eq!(format!("{}", ticket.unwrap_err()), "Title cannot be empty");
+    }
+
     assert_impl_one!(TicketNewError: std::error::Error);
 }