| 1 | #[test] |
| 2 | fn same_sender() { |
| 3 | let (tx1, _rx) = flume::unbounded::<()>(); |
| 4 | let tx2 = tx1.clone(); |
| 5 | |
| 6 | assert!(tx1.same_channel(&tx2)); |
| 7 | |
| 8 | let (tx3, _rx) = flume::unbounded::<()>(); |
| 9 | |
| 10 | assert!(!tx1.same_channel(&tx3)); |
| 11 | assert!(!tx2.same_channel(&tx3)); |
| 12 | } |
| 13 | |
| 14 | #[test] |
| 15 | fn same_receiver() { |
| 16 | let (_tx, rx1) = flume::unbounded::<()>(); |
| 17 | let rx2 = rx1.clone(); |
| 18 | |
| 19 | assert!(rx1.same_channel(&rx2)); |
| 20 | |
| 21 | let (_tx, rx3) = flume::unbounded::<()>(); |
| 22 | |
| 23 | assert!(!rx1.same_channel(&rx3)); |
| 24 | assert!(!rx2.same_channel(&rx3)); |
| 25 | } |
| 26 | |
| 27 | #[cfg(feature = "async")] |
| 28 | #[test] |
| 29 | fn same_send_sink() { |
| 30 | let (tx1, _rx) = flume::unbounded::<()>(); |
| 31 | let tx1 = tx1.into_sink(); |
| 32 | let tx2 = tx1.clone(); |
| 33 | |
| 34 | assert!(tx1.same_channel(&tx2)); |
| 35 | |
| 36 | let (tx3, _rx) = flume::unbounded::<()>(); |
| 37 | let tx3 = tx3.into_sink(); |
| 38 | |
| 39 | assert!(!tx1.same_channel(&tx3)); |
| 40 | assert!(!tx2.same_channel(&tx3)); |
| 41 | } |
| 42 | |
| 43 | #[cfg(feature = "async")] |
| 44 | #[test] |
| 45 | fn same_recv_stream() { |
| 46 | let (_tx, rx1) = flume::unbounded::<()>(); |
| 47 | let rx1 = rx1.into_stream(); |
| 48 | let rx2 = rx1.clone(); |
| 49 | |
| 50 | assert!(rx1.same_channel(&rx2)); |
| 51 | |
| 52 | let (_tx, rx3) = flume::unbounded::<()>(); |
| 53 | let rx3 = rx3.into_stream(); |
| 54 | |
| 55 | assert!(!rx1.same_channel(&rx3)); |
| 56 | assert!(!rx2.same_channel(&rx3)); |
| 57 | } |