ruby-changes:36674
From: nobu <ko1@a...>
Date: Wed, 10 Dec 2014 13:39:54 +0900 (JST)
Subject: [ruby-changes:36674] nobu:r48755 (trunk): test_cstr.rb: all wchar encodings
nobu 2014-12-10 13:39:45 +0900 (Wed, 10 Dec 2014) New Revision: 48755 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48755 Log: test_cstr.rb: all wchar encodings * test/-ext-/string/test_cstr.rb (assert_wchars_term_char): test for all wide char encodings. Modified files: trunk/test/-ext-/string/test_cstr.rb Index: test/-ext-/string/test_cstr.rb =================================================================== --- test/-ext-/string/test_cstr.rb (revision 48754) +++ test/-ext-/string/test_cstr.rb (revision 48755) @@ -41,14 +41,21 @@ class Test_StringCStr < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/-ext-/string/test_cstr.rb#L41 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/