aboutsummaryrefslogtreecommitdiffstats
path: root/test/socket/test_sockopt.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/socket/test_sockopt.rb')
-rw-r--r--test/socket/test_sockopt.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/socket/test_sockopt.rb b/test/socket/test_sockopt.rb
new file mode 100644
index 0000000000..06575f9cc3
--- /dev/null
+++ b/test/socket/test_sockopt.rb
@@ -0,0 +1,17 @@
+require 'test/unit'
+require 'socket'
+
+class TestSockOpt < Test::Unit::TestCase
+ def test_bool
+ opt = Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, true)
+ assert_equal(1, opt.int)
+ opt = Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, false)
+ assert_equal(0, opt.int)
+ opt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 0)
+ assert_equal(false, opt.bool)
+ opt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1)
+ assert_equal(true, opt.bool)
+ opt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 2)
+ assert_equal(true, opt.bool)
+ end
+end