Sha256: 03fe7a0e186715f74b8df42c0bfc7d0c35acbcc78642d04e94855074e7502e48

Contents?: true

Size: 1.03 KB

Versions: 15

Compression:

Stored size: 1.03 KB

Contents

require 'test/unit'
require 'amatch'

class TestJaroWinkler < Test::Unit::TestCase
  include Amatch

  D = 0.0005

  def setup
    @martha = JaroWinkler.new('Martha')
    @dwayne = JaroWinkler.new('dwayne')
    @dixon  = JaroWinkler.new('DIXON')
    @one    = JaroWinkler.new("one")
  end

  def test_case
    @martha.ignore_case = true
    assert_in_delta 0.961, @martha.match('MARHTA'), D
    @martha.ignore_case = false
    assert_in_delta 0.500, @martha.match('MARHTA'), D
  end

  def test_match
    assert_in_delta 0.961, @martha.match('MARHTA'), D
    assert_in_delta 0.840, @dwayne.match('DUANE'), D
    assert_in_delta 0.813, @dixon.match('DICKSONX'), D
    assert_in_delta 0, @one.match('two'), D
    assert_in_delta 0.700, @one.match('orange'), D
  end

  def test_scaling_factor
    assert_in_delta 0.1, @martha.scaling_factor, 0.0000001
    @martha.scaling_factor = 0.2
    assert_in_delta 0.978, @martha.match('MARHTA'), D
    @martha.scaling_factor = 0.5 # this is far too high
    assert_in_delta 1.028, @martha.match('MARHTA'), D
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
amatch-0.4.1 tests/test_jaro_winkler.rb
amatch-0.4.0 tests/test_jaro_winkler.rb
amatch-0.3.1 tests/test_jaro_winkler.rb
patmcnally-amatch-0.2.4 tests/test_jaro_winkler.rb
amatch-0.3.0 tests/test_jaro_winkler.rb
amatch-rbx-0.2.12 tests/test_jaro_winkler.rb
amatch-0.2.11 tests/test_jaro_winkler.rb
amatch-0.2.10 tests/test_jaro_winkler.rb
amatch-0.2.9 tests/test_jaro_winkler.rb
amatch-0.2.8 tests/test_jaro_winkler.rb
amatch-0.2.7 tests/test_jaro_winkler.rb
amatch-0.2.6 tests/test_jaro_winkler.rb
amatch-0.2.5-x86-mswin32 tests/test_jaro_winkler.rb
amatch-0.2.5 tests/test_jaro_winkler.rb
amatch-0.2.4 tests/test_jaro_winkler.rb