summaryrefslogtreecommitdiff
path: root/test/-ext-/string/test_capacity.rb
blob: b4e4fb7c02a0c49e000587147a25c4ea0c0b2e8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true
require 'test/unit'
require '-test-/string'

class Test_StringCapacity < Test::Unit::TestCase
  def test_capacity_embeded
    size = RbConfig::SIZEOF['void*'] * 3 - 1
    assert_equal size, Bug::String.capacity('foo')
  end

  def test_capacity_shared
    assert_equal 0, Bug::String.capacity(:abcdefghijklmnopqrstuvwxyz.to_s)
  end

  def test_capacity_normal
    assert_equal 128, Bug::String.capacity('1'*128)
  end
end