mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-29 05:05:37 +08:00
add test for String#<<
This commit is contained in:
@@ -8,3 +8,22 @@ describe "Strings containing null terminators" do
|
|||||||
s.size.should == 3
|
s.size.should == 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "String#<< with a codepoint" do
|
||||||
|
it "works on ASCII/BINARY strings" do
|
||||||
|
s = ""
|
||||||
|
s.encoding.should == Encoding::UTF_8
|
||||||
|
s << 3
|
||||||
|
s.should == "\x03"
|
||||||
|
|
||||||
|
s.force_encoding 'ASCII-8BIT'
|
||||||
|
s.encoding.should == Encoding::ASCII_8BIT
|
||||||
|
s << 3
|
||||||
|
s.should == "\x03\x03"
|
||||||
|
|
||||||
|
s.force_encoding 'US-ASCII'
|
||||||
|
s.encoding.should == Encoding::ASCII
|
||||||
|
s << 3
|
||||||
|
s.should == "\x03\x03\x03"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user