Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update spec library/socket/socket/gethostbyname.

Add two new specs to verify that addresses in address list returned
by Socket.gethosbyname are in 'pack' format (one spec for IPv4
addresses an the other for IPv6 ones).
  • Loading branch information...
commit de72b4a1be1f7dd8d28ca70a565ef473ef55215b 1 parent 2ddcb4d
@sdaubert sdaubert authored dbussink committed
Showing with 10 additions and 0 deletions.
  1. +10 −0 spec/ruby/library/socket/socket/gethostbyname_spec.rb
View
10 spec/ruby/library/socket/socket/gethostbyname_spec.rb
@@ -13,4 +13,14 @@
addr = Socket.gethostbyname('<any>').first;
addr.should == "0.0.0.0"
end
+
+ it "returns address list in pack format (IPv4)" do
+ laddr = Socket.gethostbyname('127.0.0.1')[3..-1];
+ laddr.should == ["\x7f\x00\x00\x01"]
+ end
+
+ it "returns address list in pack format (IPv6)" do
+ laddr = Socket.gethostbyname('::1')[3..-1]
+ laddr.should == ["\x00" * 15 + "\x01"]
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.