summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorbluemonk <ceresa@gmail.com>2013-10-26 11:15:38 +0200
committerbluemonk <ceresa@gmail.com>2013-10-26 11:15:38 +0200
commit252795d27b4d34ca43d4223d7bda9b21bb9f0dfe (patch)
tree6ca61b058d23140bb723744996bf91bb6a88aea1 /test
parent10c9350c941ba49d91d01c6fe4074551d9fe4c32 (diff)
downloadipaddress-252795d27b4d34ca43d4223d7bda9b21bb9f0dfe.tar.gz
Add RUBY_VERSION conditional test for UTF-8 encoded strings in ruby >= 2.0
Diffstat (limited to 'test')
-rw-r--r--test/ipaddress/ipv4_test.rb6
-rw-r--r--test/ipaddress/ipv6_test.rb6
2 files changed, 10 insertions, 2 deletions
diff --git a/test/ipaddress/ipv4_test.rb b/test/ipaddress/ipv4_test.rb
index 6d6386f..f144634 100644
--- a/test/ipaddress/ipv4_test.rb
+++ b/test/ipaddress/ipv4_test.rb
@@ -109,7 +109,11 @@ class IPv4Test < Test::Unit::TestCase
end
def test_method_data
- assert_equal "\254\020\n\001", @ip.data
+ if RUBY_VERSION < "2.0"
+ assert_equal "\254\020\n\001", @ip.data
+ else
+ assert_equal "\xAC\x10\n\x01".b, @ip.data
+ end
end
def test_method_to_string
diff --git a/test/ipaddress/ipv6_test.rb b/test/ipaddress/ipv6_test.rb
index 9d9ff3e..110e840 100644
--- a/test/ipaddress/ipv6_test.rb
+++ b/test/ipaddress/ipv6_test.rb
@@ -180,7 +180,11 @@ class IPv6Test < Test::Unit::TestCase
end
def test_method_data
- str = " \001\r\270\000\000\000\000\000\b\b\000 \fAz"
+ if RUBY_VERSION < "2.0"
+ str = " \001\r\270\000\000\000\000\000\b\b\000 \fAz"
+ else
+ str = " \x01\r\xB8\x00\x00\x00\x00\x00\b\b\x00 \fAz".b
+ end
assert_equal str, @ip.data
end