about summary refs log tree commit homepage
path: root/test/test_autopush.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_autopush.rb')
-rw-r--r--test/test_autopush.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test_autopush.rb b/test/test_autopush.rb
index 4d15b7b..bbd4b46 100644
--- a/test/test_autopush.rb
+++ b/test/test_autopush.rb
@@ -23,6 +23,20 @@ class TestAutopush < Test::Unit::TestCase
     @port = @srv.addr[1]
   end
 
+  def test_autopush_accessors
+    Kgio.autopush = true
+    opt = RUBY_PLATFORM =~ /freebsd/ ? TCP_NOPUSH : TCP_CORK
+    s = Kgio::TCPSocket.new(@host, @port)
+    assert_equal 0, s.getsockopt(Socket::IPPROTO_TCP, opt).unpack('i')[0]
+    assert ! s.kgio_autopush?
+    s.kgio_autopush = true
+    assert s.kgio_autopush?
+    assert_nothing_raised { s.kgio_write 'asdf' }
+    assert_equal :wait_readable, s.kgio_tryread(1)
+    assert s.kgio_autopush?
+    assert_equal 1, s.getsockopt(Socket::IPPROTO_TCP, opt).unpack('i')[0]
+  end
+
   def test_autopush_true_unix
     Kgio.autopush = true
     tmp = Tempfile.new('kgio_unix')