use crate::*;
use std::net;
#[test]
fn read_and_write() {
let listener = net::TcpListener::bind(("127.0.0.1", 0)).unwrap();
let mut output = Stream::new(net::TcpStream::connect(listener.local_addr().unwrap()).unwrap()).unwrap();
for stream in listener.incoming() {
let mut input = Stream::new(stream.unwrap()).unwrap();
input.write("tfw".to_string()).unwrap();
assert_eq!("tfw".to_string(), output.read().unwrap());
input.write("when the\n\n\n\n".to_string()).unwrap();
assert_ne!("when the\n\n\n\n", output.read().unwrap());
input.write("aaaaaaaaaa".to_string()).unwrap();
assert_eq!("aaaaaaaaaa".to_string(), output.read().unwrap());
input.write("".to_string()).unwrap();
assert_eq!("".to_string(), output.read().unwrap());
break;
}
}