diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-31 06:35:28 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-31 06:35:28 +0000 |
commit | df49fc659e70a728e000f5a9756e3f483b00acd1 (patch) | |
tree | 93d28c94ecdf043b6f043a7ec1339413bbd31d3c /test | |
parent | 54217d68b3efc40d03ff50fbec5289288fedbf66 (diff) | |
download | ruby-df49fc659e70a728e000f5a9756e3f483b00acd1.tar.gz |
String#each_grapheme_cluster and String#grapheme_clusters
added to enumerate grapheme clusters [Feature #13780]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_string.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index e88d749123..fb1cfdf68e 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -885,6 +885,46 @@ CODE end end + def test_each_grapheme_cluster + [ + "\u{20 200d}", + "\u{600 600}", + "\u{600 20}", + "\u{261d 1F3FB}", + "\u{1f600}", + "\u{20 308}", + "\u{1F477 1F3FF 200D 2640 FE0F}", + "\u{1F468 200D 1F393}", + "\u{1F46F 200D 2642 FE0F}", + "\u{1f469 200d 2764 fe0f 200d 1f469}", + ].each do |g| + assert_equal [g], g.each_grapheme_cluster.to_a + end + + assert_equal ["\u000A", "\u0308"], "\u{a 308}".each_grapheme_cluster.to_a + assert_equal ["\u000D", "\u0308"], "\u{d 308}".each_grapheme_cluster.to_a + end + + def test_grapheme_clusters + [ + "\u{20 200d}", + "\u{600 600}", + "\u{600 20}", + "\u{261d 1F3FB}", + "\u{1f600}", + "\u{20 308}", + "\u{1F477 1F3FF 200D 2640 FE0F}", + "\u{1F468 200D 1F393}", + "\u{1F46F 200D 2642 FE0F}", + "\u{1f469 200d 2764 fe0f 200d 1f469}", + ].each do |g| + assert_equal [g], g.grapheme_clusters + end + + assert_equal ["\u000A", "\u0308"], "\u{a 308}".grapheme_clusters + assert_equal ["\u000D", "\u0308"], "\u{d 308}".grapheme_clusters + end + def test_each_line save = $/ $/ = "\n" |