diff options
Diffstat (limited to 'jni/ruby/test/-ext-/string/test_set_len.rb')
-rw-r--r-- | jni/ruby/test/-ext-/string/test_set_len.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/jni/ruby/test/-ext-/string/test_set_len.rb b/jni/ruby/test/-ext-/string/test_set_len.rb new file mode 100644 index 0000000..e257cac --- /dev/null +++ b/jni/ruby/test/-ext-/string/test_set_len.rb @@ -0,0 +1,25 @@ +require 'test/unit' +require "-test-/string/string" + +class Test_StrSetLen < Test::Unit::TestCase + def setup + @s0 = [*"a".."z"].join("").freeze + @s1 = Bug::String.new(@s0) + end + + def teardown + orig = [*"a".."z"].join("") + assert_equal(orig, @s0) + end + + def test_non_shared + @s1.modify! + assert_equal("abc", @s1.set_len(3)) + end + + def test_shared + assert_raise(RuntimeError) { + assert_equal("abc", @s1.set_len(3)) + } + end +end |