summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/shared
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/shared')
-rw-r--r--spec/ruby/core/string/shared/length.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/ruby/core/string/shared/length.rb b/spec/ruby/core/string/shared/length.rb
index f387fb251c..b9eae5170f 100644
--- a/spec/ruby/core/string/shared/length.rb
+++ b/spec/ruby/core/string/shared/length.rb
@@ -23,4 +23,17 @@ describe :string_length, shared: true do
str.force_encoding('BINARY').send(@method).should == 12
end
+
+ it "returns the correct length after force_encoding(BINARY)" do
+ utf8 = "あ"
+ ascii = "a"
+ concat = utf8 + ascii
+
+ concat.encoding.should == Encoding::UTF_8
+ concat.bytesize.should == 4
+
+ concat.size.should == 2
+ concat.force_encoding(Encoding::ASCII_8BIT)
+ concat.size.should == 4
+ end
end