mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test_cstr.rb: all wchar encodings
* test/-ext-/string/test_cstr.rb (assert_wchars_term_char): test for all wide char encodings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8efe878d11
commit
d5b5338421
1 changed files with 13 additions and 6 deletions
|
@ -41,14 +41,21 @@ class Test_StringCStr < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_wchar_lstrip!
|
||||
str = Bug::String.new(" a".encode(Encoding::UTF_16BE))
|
||||
str.lstrip!
|
||||
assert_nil(str.cstr_term_char)
|
||||
assert_wchars_term_char(" a") {|s| s.lstrip!}
|
||||
end
|
||||
|
||||
def test_wchar_rstrip!
|
||||
str = Bug::String.new("a ".encode(Encoding::UTF_16BE))
|
||||
str.rstrip!
|
||||
assert_nil(str.cstr_term_char)
|
||||
assert_wchars_term_char("a ") {|s| s.rstrip!}
|
||||
end
|
||||
|
||||
def assert_wchars_term_char(str)
|
||||
result = {}
|
||||
WCHARS.map do |enc|
|
||||
s = Bug::String.new(str.encode(enc))
|
||||
yield s
|
||||
c = s.cstr_term_char
|
||||
result[enc] = c if c
|
||||
end
|
||||
assert_empty(result)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue