summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/encode_spec.rb
diff options
context:
space:
mode:
authorAndrew Konchin <andry.konchin@gmail.com>2024-07-01 15:38:25 +0300
committerBenoit Daloze <eregontp@gmail.com>2024-07-02 13:33:48 +0200
commitcee62c6738c42ce774e96e180cf2d46afb8e9cbe (patch)
tree52a37ef94e90f99f8471dbba4d6659ca5dc6c532 /spec/ruby/core/string/encode_spec.rb
parentd7af8afe1b85b8de04cd77c673b0f6ef3f3627fa (diff)
Update to ruby/spec@f8987ac
Diffstat (limited to 'spec/ruby/core/string/encode_spec.rb')
-rw-r--r--spec/ruby/core/string/encode_spec.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/spec/ruby/core/string/encode_spec.rb b/spec/ruby/core/string/encode_spec.rb
index 97dd753b62..cd449498a3 100644
--- a/spec/ruby/core/string/encode_spec.rb
+++ b/spec/ruby/core/string/encode_spec.rb
@@ -61,10 +61,22 @@ describe "String#encode" do
str.encode(invalid: :replace).should_not equal(str)
end
- it "normalizes newlines" do
- "\r\nfoo".encode(universal_newline: true).should == "\nfoo"
+ it "normalizes newlines with cr_newline option" do
+ "\r\nfoo".encode(cr_newline: true).should == "\r\rfoo"
+ "\rfoo".encode(cr_newline: true).should == "\rfoo"
+ "\nfoo".encode(cr_newline: true).should == "\rfoo"
+ end
+ it "normalizes newlines with crlf_newline option" do
+ "\r\nfoo".encode(crlf_newline: true).should == "\r\r\nfoo"
+ "\rfoo".encode(crlf_newline: true).should == "\rfoo"
+ "\nfoo".encode(crlf_newline: true).should == "\r\nfoo"
+ end
+
+ it "normalizes newlines with universal_newline option" do
+ "\r\nfoo".encode(universal_newline: true).should == "\nfoo"
"\rfoo".encode(universal_newline: true).should == "\nfoo"
+ "\nfoo".encode(universal_newline: true).should == "\nfoo"
end
it "replaces invalid encoding in source with default replacement" do