Class: ODDB::TestLevenshteinDistance

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_util/levenshtein_distance.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) test_equal



11
12
13
# File 'test/test_util/levenshtein_distance.rb', line 11

def test_equal
  assert_equal(0, 'foo'.ld('foo'))
end

- (Object) test_ld_1



14
15
16
17
18
# File 'test/test_util/levenshtein_distance.rb', line 14

def test_ld_1
  assert_equal(1, 'foo'.ld('for'))
  assert_equal(1, 'foo'.ld('fro'))
  assert_equal(1, 'foo'.ld('boo'))
end

- (Object) test_ld_1_asym



19
20
21
22
# File 'test/test_util/levenshtein_distance.rb', line 19

def test_ld_1_asym
  assert_equal(1, 'foo'.ld('fo'))
  assert_equal(1, 'fo'.ld('foo'))
end

- (Object) test_ld_2



23
24
25
26
27
28
29
30
# File 'test/test_util/levenshtein_distance.rb', line 23

def test_ld_2
  assert_equal(2, 'fooo'.ld('foar'))
  assert_equal(2, 'fooo'.ld('faor'))
  assert_equal(2, 'fooo'.ld('boor'))
  assert_equal(2, 'fooo'.ld('frao'))
  assert_equal(2, 'fooo'.ld('boro'))
  assert_equal(2, 'fooo'.ld('broo'))
end

- (Object) test_ld_2_asym



31
32
33
34
# File 'test/test_util/levenshtein_distance.rb', line 31

def test_ld_2_asym
  assert_equal(2, 'fooo'.ld('for'))
  assert_equal(2, 'foo'.ld('foar'))
end