diff options
Diffstat (limited to 'tokio-sync/tests/mpsc.rs')
-rw-r--r-- | tokio-sync/tests/mpsc.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tokio-sync/tests/mpsc.rs b/tokio-sync/tests/mpsc.rs index ce3fafc1..5b184d4e 100644 --- a/tokio-sync/tests/mpsc.rs +++ b/tokio-sync/tests/mpsc.rs @@ -255,7 +255,7 @@ fn try_send_fail() { tx.try_send("hello").unwrap(); // This should fail - assert!(tx.try_send("fail").is_err()); + assert!(tx.try_send("fail").unwrap_err().is_full()); assert_eq!(rx.next().unwrap().unwrap(), "hello"); @@ -301,6 +301,19 @@ fn dropping_rx_closes_channel() { } #[test] +fn dropping_rx_closes_channel_for_try() { + let (mut tx, rx) = mpsc::channel(100); + + let msg = Arc::new(()); + tx.try_send(msg.clone()).unwrap(); + + drop(rx); + assert!(tx.try_send(msg.clone()).unwrap_err().is_closed()); + + assert_eq!(1, Arc::strong_count(&msg)); +} + +#[test] fn unconsumed_messagers_are_dropped() { let msg = Arc::new(()); |