aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/string/reverse_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/reverse_spec.rb')
-rw-r--r--spec/ruby/core/string/reverse_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/ruby/core/string/reverse_spec.rb b/spec/ruby/core/string/reverse_spec.rb
index bade4685d9..4206b8af90 100644
--- a/spec/ruby/core/string/reverse_spec.rb
+++ b/spec/ruby/core/string/reverse_spec.rb
@@ -29,6 +29,14 @@ describe "String#reverse" do
it "reverses a string with multi byte characters" do
"微軟正黑體".reverse.should == "體黑正軟微"
end
+
+ it "works with a broken string" do
+ str = "微軟\xDF\xDE正黑體".force_encoding(Encoding::UTF_8)
+
+ str.valid_encoding?.should be_false
+
+ str.reverse.should == "體黑正\xDE\xDF軟微"
+ end
end
describe "String#reverse!" do
@@ -55,4 +63,13 @@ describe "String#reverse!" do
str.reverse!
str.should == "體黑正軟微"
end
+
+ it "works with a broken string" do
+ str = "微軟\xDF\xDE正黑體".force_encoding(Encoding::UTF_8)
+
+ str.valid_encoding?.should be_false
+ str.reverse!
+
+ str.should == "體黑正\xDE\xDF軟微"
+ end
end