diff options
Diffstat (limited to 'embassy-sync/src/pubsub/mod.rs')
| -rw-r--r-- | embassy-sync/src/pubsub/mod.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/embassy-sync/src/pubsub/mod.rs b/embassy-sync/src/pubsub/mod.rs index ae5951829..a2360a1d8 100644 --- a/embassy-sync/src/pubsub/mod.rs +++ b/embassy-sync/src/pubsub/mod.rs | |||
| @@ -755,4 +755,30 @@ mod tests { | |||
| 755 | assert_eq!(1, sub0.try_next_message_pure().unwrap().0); | 755 | assert_eq!(1, sub0.try_next_message_pure().unwrap().0); |
| 756 | assert_eq!(0, sub1.try_next_message_pure().unwrap().0); | 756 | assert_eq!(0, sub1.try_next_message_pure().unwrap().0); |
| 757 | } | 757 | } |
| 758 | |||
| 759 | #[futures_test::test] | ||
| 760 | async fn publisher_sink() { | ||
| 761 | use futures_util::{SinkExt, StreamExt}; | ||
| 762 | |||
| 763 | let channel = PubSubChannel::<NoopRawMutex, u32, 4, 4, 4>::new(); | ||
| 764 | |||
| 765 | let mut sub = channel.subscriber().unwrap(); | ||
| 766 | |||
| 767 | let publ = channel.publisher().unwrap(); | ||
| 768 | let mut sink = publ.sink(); | ||
| 769 | |||
| 770 | sink.send(0).await.unwrap(); | ||
| 771 | assert_eq!(0, sub.try_next_message_pure().unwrap()); | ||
| 772 | |||
| 773 | sink.send(1).await.unwrap(); | ||
| 774 | assert_eq!(1, sub.try_next_message_pure().unwrap()); | ||
| 775 | |||
| 776 | sink.send_all(&mut futures_util::stream::iter(0..4).map(Ok)) | ||
| 777 | .await | ||
| 778 | .unwrap(); | ||
| 779 | assert_eq!(0, sub.try_next_message_pure().unwrap()); | ||
| 780 | assert_eq!(1, sub.try_next_message_pure().unwrap()); | ||
| 781 | assert_eq!(2, sub.try_next_message_pure().unwrap()); | ||
| 782 | assert_eq!(3, sub.try_next_message_pure().unwrap()); | ||
| 783 | } | ||
| 758 | } | 784 | } |
