diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-07-12 01:47:50 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-07-12 01:47:50 +0900 |
| commit | c5f0a0256b550f853de95a57ac9cb3845d0e064a (patch) | |
| tree | 2d0e12ed0e49df5dc78e54c509d5c10b5970d669 /test/t | |
| parent | 5420895bcb14bdef8fd35d1abab09f63a003baed (diff) | |
| parent | e4249b1b9e1c568546865287bf367e4501c263de (diff) | |
| download | mruby-c5f0a0256b550f853de95a57ac9cb3845d0e064a.tar.gz mruby-c5f0a0256b550f853de95a57ac9cb3845d0e064a.zip | |
Merge pull request #4569 from dearblue/improve-string-index
Improve performance `String#index` with UTF-8
Diffstat (limited to 'test/t')
| -rw-r--r-- | test/t/string.rb | 11 |
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') |
