Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add specs to catch COW bugs in String#getbyte.

  • Loading branch information...
commit 3a715cbf9210fd80ef1fc7f431d40b7ef829047e 1 parent af6001f
Charles Oliver Nutter headius authored
Showing with 8 additions and 0 deletions.
  1. +8 −0 core/string/getbyte_spec.rb
8 core/string/getbyte_spec.rb
View
@@ -9,10 +9,18 @@
it "starts indexing at 0" do
"b".getbyte(0).should == 98
+
+ # copy-on-write case
+ str1, str2 = "fooXbar".split("X")
+ str2.getbyte(0).should == 98
end
it "counts from the end of the String if given a negative argument" do
"glark".getbyte(-1).should == "glark".getbyte(4)
+
+ # copy-on-write case
+ str1, str2 = "fooXbar".split("X")
+ str2.getbyte(-1).should == 114
end
it "returns an Integer between 0 and 255" do
Please sign in to comment.
Something went wrong with that request. Please try again.