summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2024-06-19 14:04:30 +0200
committerJean Boussier <jean.boussier@gmail.com>2024-06-19 15:11:07 +0200
commit83f57ca3d225ce06abbc5eef6aec37de4fa36d58 (patch)
tree9206acaed5f3c1dbbc415b411e51a4d0c415d696 /test
parent321ed86e93a34833bd869c6bc3f52d84b8ecce35 (diff)
String.new(capacity:) don't substract termlen
[Bug #20585] This was changed in 36a06efdd9f0604093dccbaf96d4e2cb17874dc8 because `String.new(1024)` would end up allocating `1025` bytes, but the problem with this change is that the caller may be trying to right size a String. So instead, we should just better document the behavior of `capacity:`.
Diffstat (limited to 'test')
-rw-r--r--test/-ext-/string/test_capacity.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/test/-ext-/string/test_capacity.rb b/test/-ext-/string/test_capacity.rb
index 2c6c51fdda..bcca64d85a 100644
--- a/test/-ext-/string/test_capacity.rb
+++ b/test/-ext-/string/test_capacity.rb
@@ -23,7 +23,7 @@ class Test_StringCapacity < Test::Unit::TestCase
def test_s_new_capacity
assert_equal("", String.new(capacity: 1000))
assert_equal(String, String.new(capacity: 1000).class)
- assert_equal(10_000 - 1, capa(String.new(capacity: 10_000))) # Real capa doesn't account for termlen
+ assert_equal(10_000, capa(String.new(capacity: 10_000)))
assert_equal("", String.new(capacity: -1000))
assert_equal(capa(String.new(capacity: -10000)), capa(String.new(capacity: -1000)))