summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-11 04:31:19 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-11 04:31:19 +0000
commit6e6676a2234ec190aaea02efaa31949388c02622 (patch)
treec72fed24c0017c503a5e9c1b9d5adc0c35cc3104
parentf871e8cf0d111b7dc65f25e8c03df8e9996247ea (diff)
add tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/socket/test_sockopt.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/socket/test_sockopt.rb b/test/socket/test_sockopt.rb
index 14b9c6526e..d3c831ed79 100644
--- a/test/socket/test_sockopt.rb
+++ b/test/socket/test_sockopt.rb
@@ -2,6 +2,16 @@ require 'test/unit'
require 'socket'
class TestSocketOption < Test::Unit::TestCase
+ def test_new
+ data = [1].pack("i")
+ sockopt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, data)
+ assert_equal(Socket::AF_INET, sockopt.family)
+ assert_equal(Socket::SOL_SOCKET, sockopt.level)
+ assert_equal(Socket::SO_KEEPALIVE, sockopt.optname)
+ assert_equal(Socket::SO_KEEPALIVE, sockopt.optname)
+ assert_equal(data, sockopt.data)
+ end
+
def test_bool
opt = Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, true)
assert_equal(1, opt.int)
@@ -14,4 +24,10 @@ class TestSocketOption < Test::Unit::TestCase
opt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 2)
assert_equal(true, opt.bool)
end
+
+ def test_unpack
+ sockopt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i"))
+ assert_equal([1], sockopt.unpack("i"))
+ assert_equal([1], sockopt.data.unpack("i"))
+ end
end