1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2022-11-07 20:05:30 +01:00
parent c99e4c4278
commit 83decbb62b
110 changed files with 1285 additions and 842 deletions

View file

@ -46,4 +46,26 @@ describe "String#rpartition with String" do
->{ "hello".rpartition(5) }.should raise_error(TypeError)
->{ "hello".rpartition(nil) }.should raise_error(TypeError)
end
it "handles a pattern in a superset encoding" do
string = "hello".force_encoding(Encoding::US_ASCII)
result = string.rpartition("é")
result.should == ["", "", "hello"]
result[0].encoding.should == Encoding::US_ASCII
result[1].encoding.should == Encoding::US_ASCII
result[2].encoding.should == Encoding::US_ASCII
end
it "handles a pattern in a subset encoding" do
pattern = "o".force_encoding(Encoding::US_ASCII)
result = "héllo world".rpartition(pattern)
result.should == ["héllo w", "o", "rld"]
result[0].encoding.should == Encoding::UTF_8
result[1].encoding.should == Encoding::US_ASCII
result[2].encoding.should == Encoding::UTF_8
end
end