Sha256: 00b3972f19ed6d7907d750146d0aae9af4a1f658fbe5ce2d43c5d104853a5e90

Contents?: true

Size: 1.08 KB

Versions: 65

Compression:

Stored size: 1.08 KB

Contents

require 'test_helper'
require 'milkode/common/util.rb'
require 'milkode/common/grensnip.rb'

class TestStringSnip < Test::Unit::TestCase
  def setup
  end

  def test_ranges_compound
    ranges = [0..7, 8..232, 121..150, 248..255]
    assert_equal(StringSnip.ranges_compound(ranges), [0..232, 248..255])

    ranges = [10..20, 22..30, 33..40]
    assert_equal(StringSnip.ranges_compound(ranges), [10..20, 22..30, 33..40])

    ranges = [10..30, 20..30, 30..40]
    assert_equal(StringSnip.ranges_compound(ranges), [10..40])
  end
  
  def test_string_snip
    str = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789|123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789|12345678901234567890123456789012345678901234567890123456"

    snipper = StringSnip.new
    snip_str = snipper.snip(str, [0..7, -8..-1])
    assert_equal(snip_str, str)

    snipper = StringSnip.new(64)
    snip_str = snipper.snip(str, [-8..-1, 10..20, 0..7])
    assert_equal(snip_str, "12345678<<snip>>12345678901<<snip>>90123456")
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
milkode-1.1.0 test/test_string_snip.rb
milkode-1.0.2 test/test_string_snip.rb
milkode-1.0.0 test/test_string_snip.rb
milkode-0.9.9.9 test/test_string_snip.rb
milkode-0.9.9 test/test_string_snip.rb
milkode-0.9.8 test/test_string_snip.rb
milkode-0.9.7 test/test_string_snip.rb
milkode-0.9.6 test/test_string_snip.rb
milkode-0.9.5 test/test_string_snip.rb
milkode-0.9.4 test/test_string_snip.rb
milkode-0.9.3.1 test/test_string_snip.rb
milkode-0.9.3 test/test_string_snip.rb
milkode-0.9.2 test/test_string_snip.rb
milkode-0.9.1.1 test/test_string_snip.rb
milkode-0.9.1 test/test_string_snip.rb
milkode-0.9.0 test/test_string_snip.rb
milkode-0.8.1 test/test_string_snip.rb
milkode-0.8.0 test/test_string_snip.rb
milkode-0.7.1 test/test_string_snip.rb
milkode-0.7.0 test/test_string_snip.rb