From 9869bd1d612b489df806cf95bcb56965a02424e0 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 22 Nov 2022 14:25:44 +0900 Subject: [Bug #19108] Check for the encoding of pack/unpack format --- test/ruby/test_pack.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/ruby') 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') -- cgit v1.2.3