require 'test/unit' require 'contrib/redcloth-3.0.3' require 'soks-view' class TestBruteMatch < Test::Unit::TestCase def setup @match = BruteMatch.new @match['one'] = :one @match['two'] = :two @match['one two'] = :one_two @match['two three'] = :two_three @match['three: four'] = :three_colon_four end def test_basic assert_equal( [['three: four',:three_colon_four],['two',:two]], match('two three: four or more') ) end def test_case assert_equal( [['One',:one]] , match('One') ) end def test_length assert_equal( [['one two',:one_two]], match("a one two\nthree four") ) assert_equal( [['two three',:two_three],['one',:one]], match('a one two three four') ) end def test_fullwords assert_equal( [['two',:two]], match('aone two.') ) assert_equal( [['two three',:two_three]], match('two three: fourormore') ) end def match( text ) matches = [] @match.match( text ) { |m,p| matches << [m,p] "$1" } matches end end