String#unpack1 [Feature #12752]

Returns the first value of String#unpack.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2016-12-01 14:18:32 +00:00
parent b6e137e93c
commit 306f43acfe
3 changed files with 164 additions and 125 deletions

View file

@ -837,4 +837,11 @@ EXPECTED
assert_equal addr, [buf].pack('p')
end
def test_unpack1
assert_equal 65, "A".unpack1("C")
assert_equal 68, "ABCD".unpack1("x3C")
assert_equal 0x3042, "\u{3042 3044 3046}".unpack1("U*")
assert_equal "hogefuga", "aG9nZWZ1Z2E=".unpack1("m")
end
end