about summary refs log tree commit diff
path: root/library/std/src/sys/anonymous_pipe/tests.rs
blob: f5ea583eefe0ded35d0734d4fb02c4ba190f9e2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use crate::{
    io::{Read, Write},
    pipe::pipe,
};

#[test]
fn pipe_creation_clone_and_rw() {
    let (rx, tx) = pipe().unwrap();

    tx.try_clone().unwrap().write_all(b"12345").unwrap();
    drop(tx);

    let mut rx2 = rx.try_clone().unwrap();
    drop(rx);

    let mut s = String::new();
    rx2.read_to_string(&mut s).unwrap();
    drop(rx2);
    assert_eq!(s, "12345");
}