/spec/frozen/library/socket/socket/gethostbyname_spec.rb
Ruby | 27 lines | 21 code | 5 blank | 1 comment | 5 complexity | 5b430fbe7e7dab27c2dc5670e8400724 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1
- # -*- encoding: US-ASCII -*-
- require File.expand_path('../../../../spec_helper', __FILE__)
- require File.expand_path('../../fixtures/classes', __FILE__)
- require 'socket'
- describe "Socket#gethostbyname" do
- it "returns broadcast address info for '<broadcast>'" do
- addr = Socket.gethostbyname('<broadcast>').first;
- ["broadcasthost", "255.255.255.255"].should include(addr)
- end
- it "returns broadcast address info for '<any>'" do
- 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