summaryrefslogtreecommitdiff
path: root/test/socket/test_addrinfo.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/socket/test_addrinfo.rb')
-rw-r--r--test/socket/test_addrinfo.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/socket/test_addrinfo.rb b/test/socket/test_addrinfo.rb
index d6c264b..4e232d0 100644
--- a/test/socket/test_addrinfo.rb
+++ b/test/socket/test_addrinfo.rb
@@ -274,6 +274,17 @@ class TestSocketAddrInfo < Test::Unit::TestCase
s2.close if s2 && !s2.closed?
end
+ def test_marshal
+ ai1 = AddrInfo.tcp("127.0.0.1", 80)
+ ai2 = Marshal.load(Marshal.dump(ai1))
+ assert_equal(ai1.afamily, ai2.afamily)
+ assert_equal(ai1.ip_unpack, ai2.ip_unpack)
+ assert_equal(ai1.pfamily, ai2.pfamily)
+ assert_equal(ai1.socktype, ai2.socktype)
+ assert_equal(ai1.protocol, ai2.protocol)
+ assert_equal(ai1.canonname, ai2.canonname)
+ end
+
if Socket.const_defined?("AF_INET6")
def test_addrinfo_new_inet6
@@ -290,6 +301,17 @@ class TestSocketAddrInfo < Test::Unit::TestCase
assert_equal(["::1", 80], ai.ip_unpack)
end
+ def test_marshal_inet6
+ ai1 = AddrInfo.tcp("::1", 80)
+ ai2 = Marshal.load(Marshal.dump(ai1))
+ assert_equal(ai1.afamily, ai2.afamily)
+ assert_equal(ai1.ip_unpack, ai2.ip_unpack)
+ assert_equal(ai1.pfamily, ai2.pfamily)
+ assert_equal(ai1.socktype, ai2.socktype)
+ assert_equal(ai1.protocol, ai2.protocol)
+ assert_equal(ai1.canonname, ai2.canonname)
+ end
+
end
if defined?(UNIXSocket) && /cygwin/ !~ RUBY_PLATFORM
@@ -325,5 +347,16 @@ class TestSocketAddrInfo < Test::Unit::TestCase
assert(unix_ai.unix?)
end
+ def test_marshal_unix
+ ai1 = AddrInfo.unix("/var/tmp/sock")
+ ai2 = Marshal.load(Marshal.dump(ai1))
+ assert_equal(ai1.afamily, ai2.afamily)
+ assert_equal(ai1.unix_path, ai2.unix_path)
+ assert_equal(ai1.pfamily, ai2.pfamily)
+ assert_equal(ai1.socktype, ai2.socktype)
+ assert_equal(ai1.protocol, ai2.protocol)
+ assert_equal(ai1.canonname, ai2.canonname)
+ end
+
end
end