summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-10 04:39:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-10 04:39:45 +0000
commitd5b5338421c1a9c4128fad839590fcbb6fcdea70 (patch)
treef154ef36e4be5d719a55c818d750995310c5af9d
parent8efe878d11a136c8ea209eaf1448ee6a788c4814 (diff)
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
-rw-r--r--test/-ext-/string/test_cstr.rb19
1 files 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