]> git.lizzy.rs Git - rust.git/blob - library/std/src/os/net/linux_ext/tests.rs
Rollup merge of #104148 - fmease:fix-104140, r=petrochenkov
[rust.git] / library / std / src / os / net / linux_ext / tests.rs
1 #[test]
2 fn quickack() {
3     use crate::{
4         net::{test::next_test_ip4, TcpListener, TcpStream},
5         os::net::linux_ext::tcp::TcpStreamExt,
6     };
7
8     macro_rules! t {
9         ($e:expr) => {
10             match $e {
11                 Ok(t) => t,
12                 Err(e) => panic!("received error for `{}`: {}", stringify!($e), e),
13             }
14         };
15     }
16
17     let addr = next_test_ip4();
18     let _listener = t!(TcpListener::bind(&addr));
19
20     let stream = t!(TcpStream::connect(&("localhost", addr.port())));
21
22     t!(stream.set_quickack(false));
23     assert_eq!(false, t!(stream.quickack()));
24     t!(stream.set_quickack(true));
25     assert_eq!(true, t!(stream.quickack()));
26     t!(stream.set_quickack(false));
27     assert_eq!(false, t!(stream.quickack()));
28 }