base_tokio/
tube.rs

1// Copyright 2024 The ChromiumOS Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#[cfg(test)]
6mod tests {
7    use base::Tube;
8
9    use crate::TubeTokio;
10
11    #[tokio::test]
12    async fn recv_send() {
13        let (a, b) = Tube::pair().unwrap();
14        let mut b = TubeTokio::new(b).unwrap();
15
16        let blocking_task = tokio::task::spawn_blocking(move || {
17            a.send(&5u8).unwrap();
18            a.recv::<u8>().unwrap()
19        });
20
21        assert_eq!(b.recv::<u8>().await.unwrap(), 5u8);
22        b.send(&16u8).await.unwrap();
23        assert_eq!(blocking_task.await.unwrap(), 16u8);
24    }
25}