diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-21 15:38:59 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-21 15:38:59 +0000 |
commit | da7976235fbc2986925969646071bebe3702e49f (patch) | |
tree | 83bbf6a8e03cf990369feabe6c1c9d45c69f4c85 /spec/ruby/optional/capi/string_spec.rb | |
parent | b8e389a0f3226c90e96e02e6396686a3bef6a456 (diff) |
Update to ruby/spec@7a16e01
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/optional/capi/string_spec.rb')
-rw-r--r-- | spec/ruby/optional/capi/string_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/string_spec.rb b/spec/ruby/optional/capi/string_spec.rb index 06b0c9cbf7..5ad8169e8e 100644 --- a/spec/ruby/optional/capi/string_spec.rb +++ b/spec/ruby/optional/capi/string_spec.rb @@ -558,10 +558,33 @@ describe "C-API String function" do it_behaves_like :string_value_macro, :SafeStringValue end + 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_set_len(str, 3) + str.bytesize.should == 3 + @s.RSTRING_LEN(str).should == 3 + @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_modify_expand(str, 1024) + str.bytesize.should == 3 + @s.RSTRING_LEN(str).should == 3 + @s.rb_str_capacity(str).should == 1027 + end + end + describe "rb_str_resize" do it "reduces the size of the string" do str = @s.rb_str_resize("test", 2) str.size.should == 2 + str.bytesize.should == 2 @s.RSTRING_LEN(str).should == 2 str.should == "te" end @@ -574,6 +597,7 @@ describe "C-API String function" do expected = "test".force_encoding("US-ASCII") str = @s.rb_str_resize(expected.dup, 12) str.size.should == 12 + str.bytesize.should == 12 @s.RSTRING_LEN(str).should == 12 str[0, 4].should == expected end |