Skip to content

Commit

Permalink
Adds test for ERXStringUtilities.levenshteinDistance(). wocommunity#312
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhoadley committed Nov 8, 2012
1 parent 41e6573 commit 888ef95
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private class LevenshteinExample {
/**
* Levenshtein distance between {@code s1} and {@code s2}
*/
public double d;
public int d;

/**
* Constructor
Expand All @@ -56,7 +56,7 @@ private class LevenshteinExample {
* @param d
* Levenshtein distance
*/
public LevenshteinExample(String s1, String s2, double d) {
public LevenshteinExample(String s1, String s2, int d) {
this.s1 = s1;
this.s2 = s2;
this.d = d;
Expand Down Expand Up @@ -235,12 +235,23 @@ public void testMaskStringWithCharacter4() {
}

/**
* Tests {@code ERXStringUtilities.distance(String, String)}.
* Tests {@link ERXStringUtilities#distance(String, String)}.
*/
@Test
public void testDistance() {
for (LevenshteinExample l : levs) {
assertEquals(l.d, ERXStringUtilities.distance(l.s1, l.s2), 0.00001);
}
}

/**
* Tests {@link ERXStringUtilities#levenshteinDistance(String, String)}.
*/
@Test
public void testLevenshteinDistance() {
for (LevenshteinExample l : levs) {
assertEquals(l.d,
ERXStringUtilities.levenshteinDistance(l.s1, l.s2));
}
}
}

0 comments on commit 888ef95

Please sign in to comment.