Feature #3711
Updated by nahi (Hiroshi Nakamura) almost 13 years ago
=begin class MustNotCallError < NotImplementedError ; end class IpAddrNoResolvTestCase < Test::Unit::TestCase def setup() class << IPSocket alias original_getaddress getaddress def getaddress( host ) # DNS lookups are slow and totally unnecessary for IP addresses raise MustNotCallError.new( 'IPAddr.new() must not call IPSocket.getaddress()!' ) end end end def test_ipaddr_must_not_resolve_valid_ipv4_address assert_nothing_raised { IPAddr.new( '1.2.3.4', Socket::AF_INET ) } end def test_ipaddr_must_not_resolve_invalid_ipv4_style_address assert_raise( ArgumentError ) { IPAddr.new( '1.2.3.400', Socket::AF_INET ) } end def test_ipaddr_must_not_resolve_valid_ipv6_address assert_nothing_raised { IPAddr.new( '::', Socket::AF_INET6 ) } end def test_ipaddr_must_not_resolve_invalid_ipv6_style_address assert_raise( ArgumentError ) { IPAddr.new( '::1::', Socket::AF_INET6 ) } end end =end