summaryrefslogtreecommitdiff
path: root/test/-ext-
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-11 11:17:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-11 11:17:54 +0000
commitdb3ddad3a710de4f0c6ef5d47493c5f7ba9b7384 (patch)
tree74a6b0928573200a2e3a3174f6eb76687b05860d /test/-ext-
parentbe698dbc665d1e0423fa995920ac94718216bffa (diff)
string.c: check null char
* string.c (rb_string_value_cstr): check null char in char, not in byte. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-')
-rw-r--r--test/-ext-/string/test_cstr.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/-ext-/string/test_cstr.rb b/test/-ext-/string/test_cstr.rb
index 8c0bb13..8ea86aa 100644
--- a/test/-ext-/string/test_cstr.rb
+++ b/test/-ext-/string/test_cstr.rb
@@ -14,4 +14,23 @@ class Test_StringCStr < Test::Unit::TestCase
s = Bug::String.new("abcdef")*100000
assert_equal(0, s.cstr_term, Bug4319)
end
+
+ WCHARS = [Encoding::UTF_16BE, Encoding::UTF_16LE, Encoding::UTF_32BE, Encoding::UTF_32LE]
+
+ def test_wchar_embed
+ WCHARS.each do |enc|
+ s = Bug::String.new("ab".encode(enc))
+ assert_nothing_raised(ArgumentError) {s.cstr_term}
+ end
+ end
+
+ def test_wchar_long
+ str = "abcdef"
+ n = 100
+ len = str.size * n
+ WCHARS.each do |enc|
+ s = Bug::String.new(str.encode(enc))*n
+ assert_nothing_raised(ArgumentError) {s.cstr_term}
+ end
+ end
end