diff options
author | Peter Zhu <peter@peterzhu.ca> | 2021-08-26 10:06:32 -0400 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2021-10-25 13:26:23 -0400 |
commit | a5b6598192c30187b19b892af3110a46f6a70d76 (patch) | |
tree | 4620f69a10659deb6f278b36c10ec7915194573e /spec/ruby/optional/capi | |
parent | 6374be5a8188ff5ed2c70b9f1d76672c87a0eda7 (diff) |
[Feature #18239] Implement VWA for strings
This commit adds support for embedded strings with variable capacity and
uses Variable Width Allocation to allocate strings.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4933
Diffstat (limited to 'spec/ruby/optional/capi')
-rw-r--r-- | spec/ruby/optional/capi/string_spec.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/spec/ruby/optional/capi/string_spec.rb b/spec/ruby/optional/capi/string_spec.rb index 5575ade07b..3cd88a7390 100644 --- a/spec/ruby/optional/capi/string_spec.rb +++ b/spec/ruby/optional/capi/string_spec.rb @@ -108,7 +108,7 @@ describe "C-API String function" do it "returns a string with the given capacity" do buf = @s.rb_str_buf_new(256, nil) - @s.rb_str_capacity(buf).should == 256 + @s.rb_str_capacity(buf).should >= 256 end it "returns a string that can be appended to" do @@ -682,27 +682,27 @@ describe "C-API String function" do describe "rb_str_modify_expand" do it "grows the capacity to bytesize + expand, not changing the bytesize" do str = @s.rb_str_buf_new(256, "abcd") - @s.rb_str_capacity(str).should == 256 + @s.rb_str_capacity(str).should >= 256 @s.rb_str_set_len(str, 3) str.bytesize.should == 3 @s.RSTRING_LEN(str).should == 3 - @s.rb_str_capacity(str).should == 256 + @s.rb_str_capacity(str).should >= 256 @s.rb_str_modify_expand(str, 4) str.bytesize.should == 3 @s.RSTRING_LEN(str).should == 3 - @s.rb_str_capacity(str).should == 7 + @s.rb_str_capacity(str).should >= 7 @s.rb_str_modify_expand(str, 1024) str.bytesize.should == 3 @s.RSTRING_LEN(str).should == 3 - @s.rb_str_capacity(str).should == 1027 + @s.rb_str_capacity(str).should >= 1027 @s.rb_str_modify_expand(str, 1) str.bytesize.should == 3 @s.RSTRING_LEN(str).should == 3 - @s.rb_str_capacity(str).should == 4 + @s.rb_str_capacity(str).should >= 4 end it "raises an error if the string is frozen" do |