From fcbf63e62c627deae76c1b8cb8c0876c536ed811 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 16 Mar 2020 18:49:26 +0900 Subject: Fresh start --- jni/ruby/test/-ext-/string/test_set_len.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 jni/ruby/test/-ext-/string/test_set_len.rb (limited to 'jni/ruby/test/-ext-/string/test_set_len.rb') 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 -- cgit v1.2.3