summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/shared/grapheme_clusters.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/shared/grapheme_clusters.rb')
-rw-r--r--spec/ruby/core/string/shared/grapheme_clusters.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/spec/ruby/core/string/shared/grapheme_clusters.rb b/spec/ruby/core/string/shared/grapheme_clusters.rb
index 8b666868b1..dd8c7ed5fe 100644
--- a/spec/ruby/core/string/shared/grapheme_clusters.rb
+++ b/spec/ruby/core/string/shared/grapheme_clusters.rb
@@ -9,8 +9,17 @@ describe :string_grapheme_clusters, shared: true do
a.should == ['a', 'b', "\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}", "\u{1F43E}"]
end
+ it "returns grapheme clusters for various UTF encodings" do
+ [Encoding::UTF_16LE, Encoding::UTF_16BE, Encoding::UTF_32LE, Encoding::UTF_32BE].each do |enc|
+ a = []
+ # test string: abc[rainbow flag emoji][paw prints]
+ "ab\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}\u{1F43E}".encode(enc).send(@method) { |c| a << c }
+ a.should == ['a', 'b', "\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}", "\u{1F43E}"].map { |s| s.encode(enc) }
+ end
+ end
+
it "returns self" do
s = StringSpecs::MyString.new "ab\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}\u{1F43E}"
- s.send(@method) {}.should equal(s)
+ s.send(@method) {}.should.equal?(s)
end
end