diff options
| author | Berend-Jan Lange <berendjanlange@Berend-Jans-MBP.home> | 2022-04-22 21:39:09 +0200 |
|---|---|---|
| committer | berendjan <45036733+berendjan@users.noreply.github.com> | 2022-08-13 17:38:01 +0200 |
| commit | 786e8755e7f8142c90a82351a11ad51acf5e1460 (patch) | |
| tree | 5077c576fad816bcf728f818fe7fff4ed8b18449 /library/std/src/os/net/tests.rs | |
| parent | 75b7e52e92c3b00fc891b47f5b2efdff0a2be55a (diff) | |
| download | rust-786e8755e7f8142c90a82351a11ad51acf5e1460.tar.gz rust-786e8755e7f8142c90a82351a11ad51acf5e1460.zip | |
created tcpstream quickack trait
for linux and android
Diffstat (limited to 'library/std/src/os/net/tests.rs')
| -rw-r--r-- | library/std/src/os/net/tests.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/library/std/src/os/net/tests.rs b/library/std/src/os/net/tests.rs new file mode 100644 index 00000000000..4704e315691 --- /dev/null +++ b/library/std/src/os/net/tests.rs @@ -0,0 +1,29 @@ +#[cfg(any(target_os = "android", target_os = "linux",))] +#[test] +fn quickack() { + use crate::{ + net::{test::next_test_ip4, TcpListener, TcpStream}, + os::net::tcp::TcpStreamExt, + }; + + macro_rules! t { + ($e:expr) => { + match $e { + Ok(t) => t, + Err(e) => panic!("received error for `{}`: {}", stringify!($e), e), + } + }; + } + + let addr = next_test_ip4(); + let _listener = t!(TcpListener::bind(&addr)); + + let stream = t!(TcpStream::connect(&("localhost", addr.port()))); + + t!(stream.set_quickack(false)); + assert_eq!(false, t!(stream.quickack())); + t!(stream.set_quickack(true)); + assert_eq!(true, t!(stream.quickack())); + t!(stream.set_quickack(false)); + assert_eq!(false, t!(stream.quickack())); +} |
