aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_string.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-27 02:47:49 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-27 02:47:49 +0000
commit5a75eabed5d82d6430755bdc993fe5b3c467fd31 (patch)
tree67e803b61fafc959e12ebc455b31bde28c1ec874 /test/ruby/test_string.rb
parentaaf99a76078488946742484cc4eb1d38237d60ff (diff)
downloadruby-5a75eabed5d82d6430755bdc993fe5b3c467fd31.tar.gz
Add test for String#test_insert.
* test/ruby/test_string.rb (test_insert): The test cases are written in string.c comments as a reference. [Fix GH-1173] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_string.rb')
-rw-r--r--test/ruby/test_string.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 47bd0d56af..f907a28f99 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -956,6 +956,14 @@ class TestString < Test::Unit::TestCase
assert_nil($~)
end
+ def test_insert
+ assert_equal("Xabcd", S("abcd").insert(0, 'X'))
+ assert_equal("abcXd", S("abcd").insert(3, 'X'))
+ assert_equal("abcdX", S("abcd").insert(4, 'X'))
+ assert_equal("abXcd", S("abcd").insert(-3, 'X'))
+ assert_equal("abcdX", S("abcd").insert(-1, 'X'))
+ end
+
def test_intern
assert_equal(:koala, S("koala").intern)
assert_not_equal(:koala, S("Koala").intern)