summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-22 05:02:30 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-22 05:02:30 +0000
commit9cbaeed6eda4c26a488878aeb0d47b976cc02472 (patch)
tree4aa5ee080d10eca08387cca449170851fc015f8e /test
parentcda3a0c75e25b36169c3fa56068803cca9229242 (diff)
Add some corner cases to tests for String#index.
* test/ruby/test_string.rb (TestString#test_index): Add some corner cases to tests for String#index, which might fail if ruby directly used a buggy memmem(3) implementation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_string.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 2beaef3504..2e63eff5a7 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -830,6 +830,13 @@ class TestString < Test::Unit::TestCase
assert_nil(S("hello").index(S("z")))
assert_nil(S("hello").index(/z./))
+ assert_equal(0, S("").index(S("")))
+ assert_equal(0, S("").index(//))
+ assert_nil(S("").index(S("hello")))
+ assert_nil(S("").index(/hello/))
+ assert_equal(0, S("hello").index(S("")))
+ assert_equal(0, S("hello").index(//))
+
o = Object.new
def o.to_str; "bar"; end
assert_equal(3, "foobarbarbaz".index(o))