Skip to content

Commit 8010fff

Browse files
committed
Use a binary String for rb_str_set_len() tests
* rb_str_set_len() should only be used on "buffer strings", where encoding information is ignored.
1 parent 5767b3e commit 8010fff

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

spec/ruby/optional/capi/string_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def to_str
3636
before :each do
3737
# Make a completely new copy of the string
3838
# for every example (#dup doesn't cut it).
39-
@str = "abcdefghij"[0..-1]
39+
@str = "abcdefghij".b[0..-1]
4040
end
4141

4242
it "reduces the size of the string" do
@@ -63,7 +63,6 @@ def to_str
6363
@s.rb_str_set_len(@str, 1)
6464
@str.should == "a"
6565

66-
@str.force_encoding(Encoding::UTF_8)
6766
@s.RSTRING_PTR_set(@str, 1, 'B'.ord)
6867
@s.RSTRING_PTR_set(@str, 2, 'C'.ord)
6968
@s.rb_str_set_len(@str, 3)

0 commit comments

Comments
 (0)