Keep tests for Levenshtein Distance together

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1560759 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benedikt Ritter 2014-01-23 17:10:58 +00:00
parent 64e9b7f514
commit 7a532bcc01
1 changed files with 32 additions and 33 deletions

View File

@ -1915,39 +1915,6 @@ public class StringUtilsTest {
} }
} }
@Test
public void testGetJaroWinklerDistance_StringString() {
assertEquals(0.93d, StringUtils.getJaroWinklerDistance("frog", "fog"), 0.0d);
assertEquals(0.0d, StringUtils.getJaroWinklerDistance("fly", "ant"), 0.0d);
assertEquals(0.44d, StringUtils.getJaroWinklerDistance("elephant", "hippo"), 0.0d);
assertEquals(0.91d, StringUtils.getJaroWinklerDistance("ABC Corporation", "ABC Corp"), 0.0d);
assertEquals(0.93d, StringUtils.getJaroWinklerDistance("D N H Enterprises Inc", "D & H Enterprises, Inc."), 0.0d);
assertEquals(0.94d, StringUtils.getJaroWinklerDistance("My Gym Children's Fitness Center", "My Gym. Childrens Fitness"), 0.0d);
assertEquals(0.9d, StringUtils.getJaroWinklerDistance("PENNSYLVANIA", "PENNCISYLVNIA"), 0.0d);
// exceptions
try {
StringUtils.getJaroWinklerDistance(null, null);
fail("expecting IllegalArgumentException");
} catch (final IllegalArgumentException ex) {
// empty
}
try {
StringUtils.getJaroWinklerDistance(" ", null);
fail("expecting IllegalArgumentException");
} catch (final IllegalArgumentException ex) {
// empty
}
try {
StringUtils.getJaroWinklerDistance(null, "clear");
fail("expecting IllegalArgumentException");
} catch (final IllegalArgumentException ex) {
// empty
}
}
@Test @Test
public void testGetLevenshteinDistance_StringStringInt() { public void testGetLevenshteinDistance_StringStringInt() {
// empty strings // empty strings
@ -2033,6 +2000,38 @@ public class StringUtilsTest {
} }
} }
@Test
public void testGetJaroWinklerDistance_StringString() {
assertEquals(0.93d, StringUtils.getJaroWinklerDistance("frog", "fog"), 0.0d);
assertEquals(0.0d, StringUtils.getJaroWinklerDistance("fly", "ant"), 0.0d);
assertEquals(0.44d, StringUtils.getJaroWinklerDistance("elephant", "hippo"), 0.0d);
assertEquals(0.91d, StringUtils.getJaroWinklerDistance("ABC Corporation", "ABC Corp"), 0.0d);
assertEquals(0.93d, StringUtils.getJaroWinklerDistance("D N H Enterprises Inc", "D & H Enterprises, Inc."), 0.0d);
assertEquals(0.94d, StringUtils.getJaroWinklerDistance("My Gym Children's Fitness Center", "My Gym. Childrens Fitness"), 0.0d);
assertEquals(0.9d, StringUtils.getJaroWinklerDistance("PENNSYLVANIA", "PENNCISYLVNIA"), 0.0d);
// exceptions
try {
StringUtils.getJaroWinklerDistance(null, null);
fail("expecting IllegalArgumentException");
} catch (final IllegalArgumentException ex) {
// empty
}
try {
StringUtils.getJaroWinklerDistance(" ", null);
fail("expecting IllegalArgumentException");
} catch (final IllegalArgumentException ex) {
// empty
}
try {
StringUtils.getJaroWinklerDistance(null, "clear");
fail("expecting IllegalArgumentException");
} catch (final IllegalArgumentException ex) {
// empty
}
}
/** /**
* A sanity check for {@link StringUtils#EMPTY}. * A sanity check for {@link StringUtils#EMPTY}.
*/ */