Sha256: d6009252173aba1ef63c8cb83ca2513ada886109a93166be75b84abd4458b64b

Contents?: true

Size: 689 Bytes

Versions: 3

Compression:

Stored size: 689 Bytes

Contents

# Test for facets/string/scan

require 'facets/string/scan.rb'

require 'test/unit'

class TestStringScan < Test::Unit::TestCase

  def test_mscan
    r = 'abc,def,gh'.mscan(/[,]/)
    assert( r.all?{ |md| MatchData === md } )
    assert_equal( 2, r.to_a.length )
    assert_equal( ',', r[0][0] )
    assert_equal( ',', r[1][0] )
  end

  def test_divide
    s = "<p>This<b>is</b>a test.</p>"
    d = s.divide( /<.*?>/ )
    e = ["<p>This", "<b>is", "</b>a test.", "</p>"]
    assert_equal(e, d)
  end

  def test_shatter
    s = "<p>This<b>is</b>a test.</p>"
    sh = s.shatter( /<.*?>/ )
    e = ["<p>", "This", "<b>", "is", "</b>", "a test.", "</p>"]
    assert_equal(e, sh)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.2.0 test/unit/string/test_scan.rb
facets-2.2.1 test/unit/string/test_scan.rb
facets-2.3.0 test/core/string/test_scan.rb