From 5447da4ffd471af324f3c0a9c1caebef4b780e37 Mon Sep 17 00:00:00 2001 From: Yaroslav Dynnikov <yaroslav.dynnikov@gmail.com> Date: Sun, 8 May 2022 14:51:37 +0300 Subject: [PATCH] test: mailbox --- src/mailbox.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/mailbox.rs b/src/mailbox.rs index d480f51075..780f5c7fe3 100644 --- a/src/mailbox.rs +++ b/src/mailbox.rs @@ -39,3 +39,20 @@ impl<T> Mailbox<T> { self.0.content.take() } } + +inventory::submit!(crate::InnerTest { + name: "test_mailbox", + body: || { + let mailbox = Mailbox::<u8>::new(); + assert_eq!(mailbox.receive_all(Duration::ZERO), Vec::<u8>::new()); + + mailbox.send(1); + assert_eq!(mailbox.receive_all(Duration::ZERO), vec![1]); + + mailbox.send(2); + mailbox.send(3); + assert_eq!(mailbox.receive_all(Duration::ZERO), vec![2, 3]); + + assert_eq!(format!("{mailbox:?}"), "Mailbox<u8> { .. }") + } +}); -- GitLab