From abc1fbf6b22454366d957f427ef1e2ea32eda7e8 Mon Sep 17 00:00:00 2001 From: mame Date: Thu, 15 May 2008 14:37:18 +0000 Subject: * test/ruby/test_string.rb: add tests to achieve over 90% test coverage of string.c. * test/ruby/test_m17n.rb: ditto. * test/ruby/test_symbol.rb: ditto. * test/ruby/test_pack.rb: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_pack.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/ruby/test_pack.rb') diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 85d0b7cdf..b38893757 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -63,6 +63,7 @@ class TestPack < Test::Unit::TestCase assert_equal a, a.pack("P").unpack("P*") assert_equal "a", a.pack("P").unpack("P")[0] assert_equal a, a.pack("P").freeze.unpack("P*") + assert_raise(ArgumentError) { (a.pack("P") + "").unpack("P*") } end def test_pack_p @@ -70,6 +71,7 @@ class TestPack < Test::Unit::TestCase assert_equal a, a.pack("p").unpack("p*") assert_equal a[0], a.pack("p").unpack("p")[0] assert_equal a, a.pack("p").freeze.unpack("p*") + assert_raise(ArgumentError) { (a.pack("p") + "").unpack("p*") } end def test_format_string_modified @@ -429,4 +431,14 @@ class TestPack < Test::Unit::TestCase assert_equal([0xffffffff], "\217\377\377\377\177".unpack("w"), [0xffffffff]) assert_equal([0x100000000], "\220\200\200\200\000".unpack("w"), [0x100000000]) end + + def test_modify_under_safe4 + s = "foo" + assert_raise(SecurityError) do + Thread.new do + $SAFE = 4 + s.clear + end.join + end + end end -- cgit