summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authordearblue <[email protected]>2019-07-11 22:00:01 +0900
committerdearblue <[email protected]>2019-07-11 22:09:16 +0900
commite4249b1b9e1c568546865287bf367e4501c263de (patch)
tree2d0e12ed0e49df5dc78e54c509d5c10b5970d669 /test
parent8c0d9ba1a363683bbeab8cb7c22acdb07621352d (diff)
downloadmruby-e4249b1b9e1c568546865287bf367e4501c263de.tar.gz
mruby-e4249b1b9e1c568546865287bf367e4501c263de.zip
Add UTF-8 test for `String#index`
Diffstat (limited to 'test')
-rw-r--r--test/t/string.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/t/string.rb b/test/t/string.rb
index 87d60ed72..cf145f97e 100644
--- a/test/t/string.rb
+++ b/test/t/string.rb
@@ -468,6 +468,17 @@ assert('String#index', '15.2.10.5.22') do
assert_equal nil, "hello".index("", 6)
end
+assert('String#index(UTF-8)', '15.2.10.5.22') do
+ assert_equal 0, '⓿➊➋➌➍➎'.index('⓿')
+ assert_nil '⓿➊➋➌➍➎'.index('➓')
+ assert_equal 6, '⓿➊➋➌➍➎⓿➊➋➌➍➎'.index('⓿', 1)
+ assert_equal 6, "⓿➊➋➌➍➎".index("", 6)
+ assert_equal nil, "⓿➊➋➌➍➎".index("", 7)
+ assert_equal 0, '⓿➊➋➌➍➎'.index("\xe2")
+ assert_equal nil, '⓿➊➋➌➍➎'.index("\xe3")
+ assert_equal 6, "\xd1\xd1\xd1\xd1\xd1\xd1⓿➊➋➌➍➎".index('⓿')
+end if UTF8STRING
+
assert('String#initialize', '15.2.10.5.23') do
a = ''
a.initialize('abc')