summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_pack.rb6
-rw-r--r--test/test_securerandom.rb4
2 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
index 5a19cb3d56..1463bd035b 100644
--- a/test/ruby/test_pack.rb
+++ b/test/ruby/test_pack.rb
@@ -280,6 +280,9 @@ class TestPack < Test::Unit::TestCase
assert_equal(["1"], "\x80".unpack("B1"))
assert_equal(["10"], "\x80".unpack("B2"))
assert_equal(["100"], "\x80".unpack("B3"))
+
+ assert_equal(Encoding::US_ASCII, "\xff\x00".unpack("b*")[0].encoding)
+ assert_equal(Encoding::US_ASCII, "\xff\x00".unpack("B*")[0].encoding)
end
def test_pack_unpack_hH
@@ -320,6 +323,9 @@ class TestPack < Test::Unit::TestCase
assert_equal(["10e"], "\x10\xef".unpack("H3"))
assert_equal(["10ef"], "\x10\xef".unpack("H4"))
assert_equal(["10ef"], "\x10\xef".unpack("H5"))
+
+ assert_equal(Encoding::US_ASCII, "\x10\xef".unpack("h*")[0].encoding)
+ assert_equal(Encoding::US_ASCII, "\x10\xef".unpack("H*")[0].encoding)
end
def test_pack_unpack_cC
diff --git a/test/test_securerandom.rb b/test/test_securerandom.rb
index f3e1bf0afc..f3c9a1af92 100644
--- a/test/test_securerandom.rb
+++ b/test/test_securerandom.rb
@@ -111,6 +111,10 @@ end
end
end
+ def test_hex_encoding
+ assert_equal(Encoding::US_ASCII, @it.hex.encoding)
+ end
+
def test_s_base64
assert_equal(16, @it.base64.unpack('m*')[0].size)
17.times do |idx|