diff options
author | Nobuyoshi Nakada <[email protected]> | 2022-11-22 14:25:44 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2022-12-01 17:38:33 +0900 |
commit | 9869bd1d612b489df806cf95bcb56965a02424e0 (patch) | |
tree | 1b1c53882fb5aaa0cbc48e184c4c76421decebc0 /test | |
parent | a1d341efaf0b357e7aad3700ed7551559b4fcdf8 (diff) |
[Bug #19108] Check for the encoding of pack/unpack format
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6785
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_pack.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index e1d58a2b84..2706dbfaee 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -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') |