From b0e40509c3b60242c6a1b0e67276849eea505977 Mon Sep 17 00:00:00 2001 From: eregon Date: Fri, 19 Oct 2012 13:13:32 +0000 Subject: set encoding to ASCII for appropriate String#unpack modifiers * pack.c (pack_unpack): set encoding of the 'H','h','B' and 'B' modifiers to US-ASCII. * test/ruby/test_pack.rb: tests for the above. [ruby-core:47653][Bug #7050] * test/test_securerandom.rb: tests for SecureRandom.hex from tenderlove. [ruby-core:46792][Bug #6799] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_pack.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/ruby/test_pack.rb') 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 -- cgit v1.2.3