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