Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions core/string/append_as_bytes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
str.should == "hello\xE2\x82\f+\xAC".b
end

it "truncates integers to the least significant byte" do
str = +""
str.append_as_bytes(0x131, 0x232, 0x333, bignum_value, bignum_value(1))
str.bytes.should == [0x31, 0x32, 0x33, 0, 1]
end

it "wraps negative integers" do
str = "".b
str.append_as_bytes(-1, -bignum_value, -bignum_value(1))
str.bytes.should == [0xFF, 0, 0xFF]
end

it "only accepts strings or integers, and doesn't attempt to cast with #to_str or #to_int" do
to_str = mock("to_str")
to_str.should_not_receive(:to_str)
Expand Down
Loading