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

#[test]
#[cfg(all(windows, unix, not(miri)))]
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");
}