about summary refs log tree commit diff
path: root/library/std/src/os/net/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/os/net/tests.rs')
-rw-r--r--library/std/src/os/net/tests.rs29
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()));
+}