[前][次][番号順一覧][スレッド一覧]

ruby-changes:41255

From: nobu <ko1@a...>
Date: Sun, 27 Dec 2015 11:47:55 +0900 (JST)
Subject: [ruby-changes:41255] nobu:r53327 (trunk): Add test for String#test_insert.

nobu	2015-12-27 11:47:49 +0900 (Sun, 27 Dec 2015)

  New Revision: 53327

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53327

  Log:
    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]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_string.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53326)
+++ ChangeLog	(revision 53327)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Dec 27 11:47:46 2015  Kuniaki IGARASHI  <igaiga@g...>
+
+	* test/ruby/test_string.rb (test_insert): The test cases are
+	  written in string.c comments as a reference.  [Fix GH-1173]
+
 Sun Dec 27 11:03:33 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (show_bitstack): trace stack_type value if yydebug.
Index: test/ruby/test_string.rb
===================================================================
--- test/ruby/test_string.rb	(revision 53326)
+++ test/ruby/test_string.rb	(revision 53327)
@@ -956,6 +956,14 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L956
     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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]