diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-28 05:56:00 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-28 05:56:00 +0000 |
commit | 2eb5e09ea5115ecba93efa38b0662eb28d657c1d (patch) | |
tree | 3b0e49050154776b836f09a62e8f5072d56d524e /test | |
parent | 4ab3c75bc51508db632de4050ea983a9be0309a1 (diff) | |
download | ruby-2eb5e09ea5115ecba93efa38b0662eb28d657c1d.tar.gz |
Add test for String#rstrip!
* test/ruby/test_string.rb (TestString#test_rstrip_bang): Add test
for String#rstrip!. [Fix GH-1176]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_string.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 778a817fdc..00e1f5f8ff 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -2142,6 +2142,22 @@ class TestString < Test::Unit::TestCase assert_raise(Encoding::CompatibilityError) { "\u3042".encode("ISO-2022-JP").rstrip } end + def test_rstrip_bang + s1 = S(" hello ") + assert_equal(" hello", s1.rstrip!) + assert_equal(" hello", s1) + + s2 = S("\u3042 ") + assert_equal("\u3042", s2.rstrip!) + assert_equal("\u3042", s2) + + s3 = S(" \u3042") + assert_equal(nil, s3.rstrip!) + assert_equal(" \u3042", s3) + + assert_raise(Encoding::CompatibilityError) { "\u3042".encode("ISO-2022-JP").rstrip! } + end + def test_lstrip assert_equal("hello ", " hello ".lstrip) assert_equal("\u3042", " \u3042".lstrip) |