Skip to main content

empty_reads/
empty-reads.rs

1extern crate shh;
2use std::io::Read;
3
4fn main() {
5    // if this blocks then it is failing.
6    println!("this will be printed");
7    let mut shh = shh::stdout().unwrap();
8    let mut s = String::new();
9    assert_eq!(shh.read_to_string(&mut s).unwrap(), 0); // should exit immediately and return empty string
10    assert_eq!(&s, "");
11
12    // if this blocks then it is failing.
13    eprintln!("this will be printed");
14    let mut shh = shh::stderr().unwrap();
15    let mut s = String::new();
16    assert_eq!(shh.read_to_string(&mut s).unwrap(), 0); // should exit immediately and return empty string
17    assert_eq!(&s, "");
18}