Skip to content

Commit f226c4b

Browse files
committed
Improve specs for rb_str_set_len()
1 parent ce5aceb commit f226c4b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

spec/ruby/optional/capi/string_spec.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,24 @@ def to_str
4949
@s.rb_str_set_len(@str, 8).should == "abcde\x00gh"
5050
end
5151

52-
it "updates the byte size and character size" do
52+
it "updates the byte size" do
5353
@s.rb_str_set_len(@str, 4)
5454
@str.bytesize.should == 4
55+
@str.should == "abcd"
56+
end
57+
58+
it "invalidates the character size" do
59+
@str.size.should == 10
60+
@s.rb_str_set_len(@str, 4)
5561
@str.size.should == 4
5662
@str.should == "abcd"
5763
end
5864

65+
it "invalidates the code range" do
66+
@s.rb_str_set_len(@str, 4)
67+
@str.ascii_only?.should == true
68+
end
69+
5970
it "updates the string's attributes visible in C code" do
6071
@s.rb_str_set_len_RSTRING_LEN(@str, 4).should == 4
6172
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
fails:SafeStringValue raises for tained string when $SAFE is 1
2+
fails:C-API String function rb_str_set_len on a ASCII-8BIT String invalidates the code range

0 commit comments

Comments
 (0)