[前][次][番号順一覧][スレッド一覧]

ruby-changes:40568

From: akr <ko1@a...>
Date: Wed, 18 Nov 2015 22:19:11 +0900 (JST)
Subject: [ruby-changes:40568] akr:r52647 (trunk): add tests.

akr	2015-11-18 22:19:01 +0900 (Wed, 18 Nov 2015)

  New Revision: 52647

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52647

  Log:
    add tests.

  Modified files:
    trunk/test/socket/test_socket.rb
Index: test/socket/test_socket.rb
===================================================================
--- test/socket/test_socket.rb	(revision 52646)
+++ test/socket/test_socket.rb	(revision 52647)
@@ -669,4 +669,54 @@ class TestSocket < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/socket/test_socket.rb#L669
     s1.close
     s2.close
   end
+
+  def test_udp_read_truncation
+    s1 = Addrinfo.udp("127.0.0.1", 0).bind
+    s2 = s1.connect_address.connect
+    s2.send("a" * 100, 0)
+    ret = s1.read(10)
+    assert_equal "a" * 10, ret
+    s2.send("b" * 100, 0)
+    ret = s1.read(10)
+    assert_equal "b" * 10, ret
+  ensure
+    s1.close
+    s2.close
+  end
+
+  def test_udp_recv_truncation
+    s1 = Addrinfo.udp("127.0.0.1", 0).bind
+    s2 = s1.connect_address.connect
+    s2.send("a" * 100, 0)
+    ret = s1.recv(10, Socket::MSG_PEEK)
+    assert_equal "a" * 10, ret
+    ret = s1.recv(10, 0)
+    assert_equal "a" * 10, ret
+    s2.send("b" * 100, 0)
+    ret = s1.recv(10, 0)
+    assert_equal "b" * 10, ret
+  ensure
+    s1.close
+    s2.close
+  end
+
+  def test_udp_recvmsg_truncation
+    s1 = Addrinfo.udp("127.0.0.1", 0).bind
+    s2 = s1.connect_address.connect
+    s2.send("a" * 100, 0)
+    ret, addr, rflags = s1.recvmsg(10, Socket::MSG_PEEK)
+    assert_equal "a" * 10, ret
+    assert_equal Socket::MSG_TRUNC, rflags & Socket::MSG_TRUNC
+    ret, addr, rflags = s1.recvmsg(10, 0)
+    assert_equal "a" * 10, ret
+    assert_equal Socket::MSG_TRUNC, rflags & Socket::MSG_TRUNC
+    s2.send("b" * 100, 0)
+    ret, addr, rflags = s1.recvmsg(10, 0)
+    assert_equal "b" * 10, ret
+    assert_equal Socket::MSG_TRUNC, rflags & Socket::MSG_TRUNC
+  ensure
+    s1.close
+    s2.close
+  end
+
 end if defined?(Socket)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]