From d5b5338421c1a9c4128fad839590fcbb6fcdea70 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 10 Dec 2014 04:39:45 +0000 Subject: [PATCH] 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 --- test/-ext-/string/test_cstr.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/-ext-/string/test_cstr.rb b/test/-ext-/string/test_cstr.rb index f6a5d07c9b..e5979ec60b 100644 --- a/test/-ext-/string/test_cstr.rb +++ b/test/-ext-/string/test_cstr.rb @@ -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