mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
[Bug #19108] Check for the encoding of pack/unpack format
This commit is contained in:
parent
a1d341efaf
commit
9869bd1d61
Notes:
git
2022-12-01 08:38:52 +00:00
2 changed files with 16 additions and 0 deletions
|
@ -22,6 +22,20 @@ class TestPack < Test::Unit::TestCase
|
|||
assert_equal(x, x.pack("l").unpack("l"))
|
||||
end
|
||||
|
||||
def test_ascii_incompatible
|
||||
assert_raise(Encoding::CompatibilityError) do
|
||||
["foo"].pack("u".encode("UTF-32BE"))
|
||||
end
|
||||
|
||||
assert_raise(Encoding::CompatibilityError) do
|
||||
"foo".unpack("C".encode("UTF-32BE"))
|
||||
end
|
||||
|
||||
assert_raise(Encoding::CompatibilityError) do
|
||||
"foo".unpack1("C".encode("UTF-32BE"))
|
||||
end
|
||||
end
|
||||
|
||||
def test_pack_n
|
||||
assert_equal "\000\000", [0].pack('n')
|
||||
assert_equal "\000\001", [1].pack('n')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue