summaryrefslogtreecommitdiff
path: root/test/-ext-/string
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-01 08:13:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-01 08:13:43 +0000
commitd58f17f37d3c169d7acfe3860872519d44144ddf (patch)
tree5aa54361ef7d9b2f5847d6202de5cd27646df769 /test/-ext-/string
parent41cbb7f05010b4f37490059ff8f5e52b4f1f8538 (diff)
string.c: no frozen error at cstr
* string.c (rb_string_value_cstr): should not raise on frozen string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-/string')
-rw-r--r--test/-ext-/string/test_cstr.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/-ext-/string/test_cstr.rb b/test/-ext-/string/test_cstr.rb
index 99c1325..4be2cc9 100644
--- a/test/-ext-/string/test_cstr.rb
+++ b/test/-ext-/string/test_cstr.rb
@@ -17,6 +17,24 @@ class Test_StringCStr < Test::Unit::TestCase
assert_equal(0, s.cstr_term, Bug4319)
end
+ def test_frozen
+ s0 = Bug::String.new("abcdefgh"*8)
+
+ [4, 4*3-1, 8*3-1, 64].each do |n|
+ s = s0[0, n]
+ s.cstr_unterm('x')
+ s.freeze
+ assert_equal(0, s.cstr_term)
+ WCHARS.each do |enc|
+ s = s0.encode(enc)
+ s.set_len(n - n % s[0].bytesize)
+ s.cstr_unterm('x')
+ s.freeze
+ assert_equal(0, s.cstr_term)
+ end
+ end
+ end
+
WCHARS = [Encoding::UTF_16BE, Encoding::UTF_16LE, Encoding::UTF_32BE, Encoding::UTF_32LE]
def test_wchar_embed