summaryrefslogtreecommitdiff
path: root/test/-ext-
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-11 11:17:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-11 11:17:59 +0000
commitb271a8c98d7301482d5b4eb2c7d79b7e1a1fc368 (patch)
tree1d8dafbbbfc506d1b562fc78984ccf42d18599c6 /test/-ext-
parentdb3ddad3a710de4f0c6ef5d47493c5f7ba9b7384 (diff)
string.c: multi-byte terminator
* string.c (rb_string_value_cstr): fill minimum length of the encoding as the terminator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-')
-rw-r--r--test/-ext-/string/test_cstr.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/-ext-/string/test_cstr.rb b/test/-ext-/string/test_cstr.rb
index 8ea86aa..f691da6 100644
--- a/test/-ext-/string/test_cstr.rb
+++ b/test/-ext-/string/test_cstr.rb
@@ -19,18 +19,24 @@ class Test_StringCStr < Test::Unit::TestCase
def test_wchar_embed
WCHARS.each do |enc|
- s = Bug::String.new("ab".encode(enc))
+ s = Bug::String.new("\u{4022}a".encode(enc))
assert_nothing_raised(ArgumentError) {s.cstr_term}
+ s.set_len(s.bytesize / 2)
+ assert_equal(1, s.size)
+ assert_equal(0, s.cstr_term)
end
end
def test_wchar_long
- str = "abcdef"
+ str = "\u{4022}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}
+ s.set_len(s.bytesize / 2)
+ assert_equal(len / 2, s.size)
+ assert_equal(0, s.cstr_term)
end
end
end