Skip to content

Commit

Permalink
* lib/ipaddr.rb (to_s, test_to_s): too many colons with some cases.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
unak committed Jan 19, 2005
1 parent 30b6cf5 commit 2512210
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Wed Jan 19 18:02:19 2005 NAKAMURA Usaku <[email protected]>

* lib/ipaddr.rb (to_s, test_to_s): too many colons with some cases.

Wed Jan 19 01:16:30 2005 Tanaka Akira <[email protected]>

* lib/resolv.rb (Resolv::DNS::Config.parse_resolv_conf): ignore
Expand Down
6 changes: 5 additions & 1 deletion lib/ipaddr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def to_s
break if str.sub!(/\b0:0\b/, ':')
break
end
str.sub!(/:{3,}/, '::')

if /\A::(ffff:)?([\da-f]{1,4}):([\da-f]{1,4})\Z/i =~ str
str = sprintf('::%s%d.%d.%d.%d', $1, $2.hex / 256, $2.hex % 256, $3.hex / 256, $3.hex % 256)
Expand Down Expand Up @@ -602,7 +603,6 @@ def test_s_new
IPAddr.new(*args)
}
}
end

def test_s_new_ntoh
addr = ''
Expand Down Expand Up @@ -674,6 +674,10 @@ def test_ip6_int
}
end

def test_to_s
assert_equal("3ffe:0505:0002:0000:0000:0000:0000:0001", IPAddr.new("3ffe:505:2::1").to_string)
assert_equal("3ffe:505:2::1", IPAddr.new("3ffe:505:2::1").to_s)
end
end

class TC_Operator < Test::Unit::TestCase
Expand Down

0 comments on commit 2512210

Please sign in to comment.