Sha256: cca25165513ebc96ad20be106fff574586f8e269e7eb59fcc01add024ed2b3c4
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
require 'test_helper' require 'gren/common/util' require 'gren/common/grensnip' 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gren-1.0.2 | test/test_string_snip.rb |
gren-1.0.1 | test/test_string_snip.rb |
gren-1.0.0 | test/test_string_snip.rb |